【发布时间】:2015-05-07 09:03:05
【问题描述】:
我正在尝试将我的广告放入表格中。我想在一行中显示三个最受欢迎的广告在主页上。然而,信息和照片根本没有正确显示,它们遍布整个页面。有人可以告诉我应该在哪里放置 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");?>
【问题讨论】:
-
如果您有实时网址,您能否发布实时网址,以便我们查看输出:)
-
啊抱歉@DavidAnderton它没有直播:((
-
整页?可以加个截图吗?
-
这很难理解,但我相信这与
<div id="ads"><table>在while循环内的事实有关,它应该在它之前,特别是因为你要关闭这些标签循环结束后。