mysql_fetch_assoc只返回1个结果

时间:2011-08-02 19:57:48

标签: php

mysql_fetch_assoc只获取一条记录(检查数据库方面的一切都很好)
Php代码:

<?php 
$folder_id = $_GET['folder_id'];
$query = mysql_query("SELECT * FROM gallery_photos WHERE folder_id = $folder_id");

if (mysql_num_rows($query) == 0)
{
    echo '<h2>Sorry, you cannot change a folders photo cover if that folder has 
         no    photos in it<br /> <a href="gallery.albums.php?fder_id='
         .$folder_id.'">Back to the folder</a><h2>';
}
else
{
    while ($row = mysql_fetch_assoc($query))
    {
        echo '<img src="gallery_photos/'.$row['photo_name'].'" width="200"';
    }
}
?>

1 个答案:

答案 0 :(得分:3)

您没有关闭HTML IMG标记。将/>添加到您的代码中。

echo '<img src="gallery_photos/'.$row['photo_name'].'" width="200" />';