mysql_fetch_assoc
只取一個記錄
PHP代碼(東西都好檢查數據庫端):mysql_fetch_assoc只返回1個結果
<?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"';
}
}
?>
您能告訴我們一些DB數據嗎?你確定它應該返回多行嗎? –
你試過例如mysql_fetch_array與assoc?順便說一句,你的代碼中有一個好奇的sql注入漏洞。 – Zaffy