PHP While() Stop Looping

Posted by Axel on Stack Overflow See other posts from Stack Overflow or by Axel
Published on 2010-03-15T02:13:59Z Indexed on 2010/03/15 2:19 UTC
Read the original article Hit count: 295

Filed under:
|

Hi,

i have a php loop which displays only one record even if there is hundreds.

here is the code:

<?php

$result1 = mysql_query("SELECT * FROM posts") or die(mysql_error());  
$numexem = mysql_num_rows($result1);
$s="0";

while($s<$numexem){
$postid=mysql_result($result1,$s,"id");
echo "Post id:".$postid;

$result2 = mysql_query("SELECT * FROM pics WHERE postid='$postid'") or die(mysql_error());  
$rows = mysql_fetch_array($result2) or die(mysql_error());
$pnum = mysql_num_rows($result2);

echo " There is ".$pnum." Attached Pictures";

$s++;
}

?>

I'm wondering if the loop stop because there is other SQL query inside it or what? and i don't think so.

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql