php - While loop not working as expected with variable -
php - While loop not working as expected with variable -
the next code works fine when remove && $f<4
, in, doesn't work.
php:
$titles=array(); $f=0; while ($row=mysql_fetch_assoc($query) && $f<4){ //this line doesn't work $titles[]=$row['questiontitle']; echo "<div class='questionpreview'>$titles[$f]</div>"; $f++; }
if interpret correctly think having precedence problem. seek this:
while (($row=mysql_fetch_assoc($query)) && ($f<4)){
php while-loop
Comments
Post a Comment