2013-07-15 56 views
0

這裏是我的代碼SQL選擇當前圖像的代碼

@$sql="select * from mp_images where id='5' and status='0'"; 
@$query=mysql_query($sql); 
while(@$row=mysql_fetch_array($query)) 
{ 
    @$image=$row ['photo']; 
?> 
<img src="image/<?php echo $image; ?>" width="360" height="150"> 
<?php 
} 
?> 

我想顯示當前最新的圖像我將它導入數據庫後

+0

你得到任何錯誤? –

+1

@VivekSadh:OP在他[壓制](http://php.net/manual/en/language.operators.errorcontrol.php)時會如何得到錯誤? – eggyal

+0

@eggyal感謝您的信息。我從來不知道@是用來抑制錯誤信息的。謝謝:) –

回答

1

通過ID就命令他們

@$sql="select * from mp_images where status='0' order by id desc limit 1"; 
+0

嗨..感謝您的答案,但我只想只顯示1個最近/最新的圖像。剛纔它顯示了列表。如何做到這一點,謝謝... – user2582674

+0

只是改變了代碼,只返回1張圖片。 –