我试图将我的广告放到桌子上。我想在主页上一行显示三个最受欢迎的广告。但是,信息和照片根本无法正常显示,而且它们遍布整个页面。有人能告诉我在哪里放置while循环的结束标记吗?这是整个代码。
<?php include("header.php");?>
<!-- Left SIDEBAR -->
<?php include("sidebar.php");?>
<!-- Right CONTENT -->
<div id="right_content">
<h1>Our most popular ads...</h1>
<?php include("functions/connect.php");
$sql = "SELECT * FROM horses ORDER BY likes DESC LIMIT 3";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "";
// output data of each row
while($row = $result->fetch_assoc()) {
$hid=$row['HorseID'];
// Get image
$sqlimg= "SELECT * FROM images where Horse_ID='$hid'";
$resultimg = $conn->query($sqlimg);
$rowimg = $resultimg->fetch_assoc() ;
?>
<div id="ads">
<table>
<tr>
<td><img src="uploads/horse1.jpg"></td>
</tr>
<tr>
<td>
<?php echo $row['HorseName']; ?>
</td>
</tr>
<?php }
} else {
?>
<br />
<div id="alert">There are no horses to display at the moment.</div>
<?php
}
$conn->close();
?>
</table>
</div>
</div>
<?php include("footer.php");?>
答案 0 :(得分:0)
解决! 该表必须浮动才能使图像彼此相邻显示。我将桌子向左浮动,所有图像都对齐了。 感谢大家的贡献。