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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -