【发布时间】:2018-06-19 04:06:37
【问题描述】:
我正在开发一个非常简单的网上商店,它应该在 2 个<td> 乘以 4 个<tr> 的表格中回显不同的产品,但现在它只向下显示不同的产品。希望这里有人可以帮助我。
$result=mysql_query("select * from products");
while($row=mysql_fetch_array($result)) {
$artikel = '<div style="background-color:#E3E3E3;width:200px;height:200px;"><a href=""><img style="padding-top:10px;padding-left:25px;width:150px;height:150px;" src="'.htmlspecialchars($row['picture']).'"></a><br><div align="center"><b>'.htmlspecialchars($row['name']).'</b><br><h6>€'.htmlspecialchars($row['price']).'</h6></div></div>';
echo '<table><tr><td>'.$artikel.'</td>';
echo '</table>';
}
【问题讨论】:
-
使用 PDO 和 fetchAll(PDO::FETCH_ASSOC)
标签: php mysql html-table