开发者

php mysql whats wrong here

开发者 https://www.devze.com 2023-02-05 11:46 出处:网络
what am i doing wrong here: $numrow =mysql_num_rows($display); echo \'<br>\'.$numrow; $printout=mysql_fetch_assoc($display);

what am i doing wrong here:

$numrow =  mysql_num_rows($display);
echo '<br>'.$numrow;
$printout=mysql_fetch_assoc($display);
print_r($printout);

This outputs:

40Array ( [id] => 97132 ) 

So it shows that their are 40 rows, which is good, but I want it to output all 40 of the ellements that the mysql q开发者_JAVA百科uery returns...


Try

$numrow =  mysql_num_rows($display);
echo '<br>'.$numrow;
while($printout=mysql_fetch_assoc($display)){
    print_r($printout);
}

As reaction to your comment: If you want just the id's you can do this

$numrow =  mysql_num_rows($display);
echo '<br>'.$numrow;
while($printout=mysql_fetch_assoc($display)){
    echo $printout['id'];
}


@David19801: Try --

while($printout = mysql_fetch_assoc($display))
{
   echo $printout['id'] . "<br>\n";
}
0

精彩评论

暂无评论...
验证码 换一张
取 消