Re: [Newbie] switch, if, or something to choose queries and echo formatting--PLEASE help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux