Re: [Newbie] switch, if, or something to choose queries and echo formatting--PLEASE help
| From: | Antoine | Date: | Sat, 25 Sep 2004 09:04:16 +0000 |
| Subject: | Re: [Newbie] switch, if, or something to choose queries and echo formatting--PLEASE help | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-36384@lists.php.net to get a copy of this message | ||
> So I attempted to do this:
> switch($_GET[page]){
> $count=1;
> $table = mysql_query("SELECT * FROM thumbs",$db);
> echo("<table border='0' cellspacing='1' cellpadding='1'
> width='300'
> align='center'><tr>");
> while ( $r = mysql_fetch_array($table) ) :
> if ($count==4){
> echo ("</tr><tr><td span='4'><img
> src='images/spacer.gif' height='10'
> width='1'></td></tr><tr>");
> $count=1;
> }else{
> $id=$r["id"];
> $pic=$r["pic"];
> $thumb=$r["thumb"];
> $pname=$r["pname"];
> $pcom=$r["pcom"];
> echo("<td align='left' valign='top' width='100'><a
> href='$pic'
> target='blank'><img src='$thumb'
> border='0' align='left'></a><br
>
> clear='all'><b>$pname</b><br><i>$pcom</i></td>");
> $count++;
> }
> endwhile;
> break;
>
> Which did not work. I wondered if that was "too much" for the case or if
> you couldn't nest. PHP.net says "The switch statement executes line by line
> (actually, statement by statement). In the beginning, no code is executed.
> Only when a case statement is found with a value that matches the value of
> the switch expression does PHP begin to execute the statements. PHP
> continues to execute the statements until the end of the switch block, or
> the first time it sees a break statement." Which made me think
> otherwise--but, hey, something's wrong.
Yip, the logic of the switch statement. You simply don't have a case
statement. I must confess I don't understand fully what you are trying
to do yet but I don't think this is the way to go. The above extract
should be enough to see what I mean... "Only when a case statement is
found with a value that matches the value of the switch expression
does PHP begin to execute the statements." You don't have one so... it
won't ever start!
Cheers
Antoine
--
G System, The Evolving GUniverse - http://www.g-system.at