Forum Moderators: coopster

Message Too Old, No Replies

loop problems

want to do a loop with a link

         

UnikRasu

1:48 pm on Dec 14, 2002 (gmt 0)

10+ Year Member



hello

i want to do a loop that makes an link to a pages

every times the loop end i want a letter to increase. this letter is a variable in the link like this

$a = a; // this shall increase its value to b and c up to z

and the link shall be like this i thing

<a href="page.php?a=$a">$a</a>

this page is a search funktion were i want to search on the first letter in names. and i dont want to write a lik to every letter instead i want a script to do it for me

please help me

/ rasu

andreasfriedrich

3:15 pm on Dec 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



for($i='a';$i<>'aa';$i++) { 
printf('<a href="page.php?a=%s">%s</a> ', $i, $i);
}

UnikRasu

4:42 pm on Dec 14, 2002 (gmt 0)

10+ Year Member



hello thanks what meens whit printf

and what does %s
and in the printf string what is the two last , $i, $i

andreasfriedrich

4:55 pm on Dec 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[php.net...]

UnikRasu

5:11 pm on Dec 14, 2002 (gmt 0)

10+ Year Member



helo i dont understand what it meens in that pages so can you try to explain it for me pleas

andreasfriedrich

5:48 pm on Dec 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The PHP manual is available in all these languages and you are trying to tell me that you do not understand one of them.

English [php.net] ¦ Brazilian Portuguese [php.net] ¦ Czech [php.net] ¦ Dutch [php.net] ¦ Finnish [php.net] ¦ French [php.net] ¦ German [php.net] ¦ Hungarian [php.net] ¦ Italian [php.net] ¦ Japanese [php.net] ¦ Korean [php.net] ¦ Polish [php.net] ¦ Romanian [php.net] ¦ Russian [php.net] ¦ Slovak [php.net] ¦ Slovenian [php.net] ¦ Spanish [php.net] ¦ Swedish [php.net] ¦ Turkish [php.net]

If it is so indeed then Iīd really like to know whether this is a language barrier thing or whether it is the actual programming stuff thatīs causing you problems.

These fora are not intended to provide you with paraphrased copies of the original documentation. I just canīt believe that there is nothing on printf [php.net] that you understand. Output a formatted string does not seem to be terribly hard to understand.

I wouldnīt have had any problem if you said you looked at the page and were wondering what the void in front of the printf meant. I would have gladly answered that. My problem lies with people who do not seem to work as hard prior to asking a question as I try to work when answering questions. In this respect I do sympathize with the master who prior to leaving for his journey provides his three servants with 10, 5 and 1 talents and on his return is ok with the first two servants who invested wisely but very angry with the one who still had only one. And to be sure it wasnīt the fact that he had still only one talent but that he didnīt even try to gain more but burried it instead for fear of losing even as little as he had.

printf outputs a formatted string. The format is given as the first argument to the function. This format string may contain placeholders that start with a percent sign. Their meaning is explained in the sprintf [php.net] documentation. Any additional arguments to printf are used to substitute the placeholders with their value.

Sorry if this sounds too harsh, but having to answer such questions is no fun for me. There is nothing much for me to gain from doing so.

Andreas