我有以下代码来显示来自 mysql 数据库的六个产品块。它显示为两列三行,我在六个位置中的每一个位置都获得了单独的照片和正确的页面链接,但是第一列中三个产品的 alt 标签在第二列中重复。我不知道为什么。有什么想法和改进代码的方法吗?
<?php
// create query
$query = "SELECT * FROM photogear WHERE qty != 0 ORDER BY id DESC LIMIT 6";
// execute query
$result = mysql_query($query) or die(MYSQL_ERROR);
?>
<table>
<?php
while($row = mysql_fetch_array($result)){
$product2=$row['product'];
$img2=$row['img'];
$manuid2=$row['manuid'];
$id2=$row['id'];
$price=$row['price'];
//GET MANUFACTURER FOR DISPLAY IN img title
$manu_q = "SELECT * FROM manufacturers WHERE manuid = '$manuid2' ORDER BY name";
$manu_r = mysql_query($manu_q) or die(mysql_error());
$manu_info = mysql_fetch_array($manu_r);
$name2=$manu_info['name'];
?>
<tr>
<td>
<?php // for each product show photo with a link to product page
echo "<a href='product-".$row['id']."'><img src='".$row['img']."'alt='$name2,$product2 $price' title='$name2 $product2 £$price' width='85'></a>";
?>
<?php $row=mysql_fetch_assoc($result); // make one record out.?>
</td>
<td>
<?php // for each product show photo with a link to product page
echo "<a href='product-".$row['id']."'><img src='".$row['img']."' alt='$name2, $product2 $price' title='$name2 $product2 £$price' width='85'></a>";?>
</td>
</tr>
<?php
} // End loops.
?>
</table>
非常感谢任何帮助