我想把我的mysql記錄取到一個表格中,每個單元格只能有一個圖像。使用PHP獲取mysql記錄到一個html表格
問題是,照片複製5次,根據我需要填寫每一行的數量。
這裏是我的代碼:
<table width="%" border="1" bordercolor="#F7F7F7" align="center" cellspacing="10" cellpadding="5">
<tr>
<?
for($i=0;$i<=5;$i++)
{
echo "<td width=125 height=125><img width=125 height=125 src=images/".$info['photo'] ."></td>";
} }?>
</tr>
</table>
我怎樣才能糾正這個代碼,以使每張照片取一次爲每個小區?
*****編輯*****
我把同時在表內,並取現是好的,但它仍然在同一行中取的,我需要做什麼來阻止直到我有5個單元格在同一行中,然後繼續獲取新行。
<table width="%" border="1" bordercolor="#F7F7F7" align="center" cellspacing="10" cellpadding="5">
<tr>
<?
while($info = mysql_fetch_array($data ))
{
?>
<td width=125 height=125 ><img width=125 height=125 src=images/<? echo ($info['photo']); ?>></td>
<? } ?>
</tr>
重複的[如何用數據庫中的值創建php 2列表?](http://stackoverflow.com/questions/7299913/how-to-create-php-2-column-table-with-values - 從數據庫) –
可以幫助我這個:) –