这是我迄今为止的输出代码。正如预期的那样,它目前显示彼此之下的所有内容。格式化PHP/HTML中的MySQL查询
<table id="dslrTable">
<?php
while($row = mysqli_fetch_assoc($result)) { ?>
<?php echo "<tr><td> <a href=model.php?id=" . $row["ID"] . ">" . "<img src=images/" . $row["Image URL"] . " </a></td></tr>"; ?>
<?php echo "<tr><td> <a href=model.php?id=" . $row["ID"] . ">" . $row["Make"] . " " . $row["Model"] . " </a></td><tr>"; ?>
<?php echo "<tr><td> <a href=#.php>[add to compare] </a> </td></tr>"; ?>
<?php } ?>
</table>
我想实现的是在数据库中每行三个tr。图片,制作/模型,然后是超链接。 4“结果”后,然后做一个新的tr。像这样的东西。
<table>
<tr>
<td>Image 1</td>
<td>Image 2</td>
<td>Image 3</td>
<td>Image 4</td>
</tr>
<tr>
<td>Make and Model 1</td>
<td>Make and Model 2</td>
<td>Make and Model 3</td>
<td>Make and Model 4</td>
</tr>
<tr>
<td>Hyperlink 1</td>
<td>Hyperlink 2</td>
<td>Hyperlink 3</td>
<td>Hyperlink 4</td>
</tr>
<tr>
<td>Image 5</td>
<td>Image 6</td>
<td>Image 7</td>
<td>Image 8</td>
</tr>
<tr>
<td>Make and Model 5</td>
<td>Make and Model 6</td>
<td>Make and Model 7</td>
<td>Make and Model 8</td>
</tr>
<tr>
<td>Hyperlink 5</td>
<td>Hyperlink 6</td>
<td>Hyperlink 7</td>
<td>Hyperlink 8</td>
</tr>
</table>
并为此继续下去,直到我的while循环停止。我知道我需要使用模块除了计数器变量,但我不能让它工作。
任何帮助表示赞赏,谢谢。
尽管此代码可以回答这个问题,提供有关为什么和/或如何代码回答了这个问题提高了其长期价值的其他方面。 –