【发布时间】:2012-06-15 05:48:00
【问题描述】:
以下是我的代码,我试图在其中显示来自同一个表但在具有不同 ID 的 HTML 表的不同列中的值,例如假设我的表有三列,然后在每一列中显示不同的值
我只希望我各自的 id 在同一张表中显示的数据的每一列上发生变化
类似于:ID1 的值 | ID2 的值 | ID3的值
但目前我的工作时间是这样的: ID1 的值 | ID1 的值 | ID1的值
请告诉我如何修复以下代码:
<table width="714" height="318" border="0" align="right" cellpadding="2" cellspacing="0">
<?php $count=0; do {
{ ++$count;
?> <tr>
<td width="231" height="288" valign="top" background="images/viv.png"><div align="center"><img src="get.php?id=<?php echo $row_Recordset1['ID']; ?>" width="270" height="270" /><br />
<br />
<a href="get_deal.php?id=<?php echo $row_Recordset1['ID']; ?>"><img src="button.png" width="182" height="36" border="0" /></a><br />
<br />
</div></td>
<td width="231" valign="top" background="images/viv.png"><div align="center"><img src="get.php?id=<?php echo $row_Recordset1['ID']; ?>" width="270" height="270" /><br />
<br />
<a href="get_deal.php?id=<?php echo $row_Recordset1['ID']; ?>"><img src="button.png" width="182" height="36" border="0" /></a><br />
<br />
</div></td>
<td width="231" valign="top" background="images/viv.png"><div align="center"><img src="get.php?id=<?php echo $row_Recordset1['ID']; ?>" width="270" height="270" /><br />
<br />
<a href="get_deal.php?id=<?php echo $row_Recordset1['ID']; ?>"><img src="button.png" width="182" height="36" border="0" /></a><br />
<br />
</div></td>
</tr>
<tr>
<td height="23" valign="top"> </td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<?php }
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
if ($count == 0)
echo '<span style="font-family:Tahoma;color:white;font-size:200%">No Deals Available</span>'; ?>
</table></td>
</tr>
</table>
【问题讨论】:
-
如果您使用表格显示,为什么不使用
而不是 ? -
您确定这按您的预期工作吗?似乎对于循环的第一次迭代,
$row_Recordset1不会被设置,你最终会得到像<a href="get_deal.php?id=">这样的链接。这是因为您使用的是do{...} while()循环而不是标准的while(){...}循环。