我被困在下面的代碼...根據我的理解,下面的代碼應顯示在我的數據庫中創建的所有行數據...但即時只獲得1行數據在我的產品頁面上的結果只有一個產品...請幫助...查詢只返回1行內容
<?php
include 'core/database/connect.php';
include 'core/includes/listhead.php';
$dynamiclist = "";
$sql = mysql_query("SELECT * FROM `index` ORDER BY price1 LIMIT 2");
$hotelcount = mysql_num_rows($sql);
if($hotelcount > 0) {
while($row = mysql_fetch_array($sql)) {
$id = $row['index_id'];
$pic = $row['main_pic'];
$country = $row['country1'];
$destination = $row['destination1'];
$price = $row["price1"];
$dynamiclist = '<div class=/"offset-2/">
<div class="col-md-4 offset-0">
<div class="listitem2">
<a href="" data-footer="A custom footer text" data-title="A random title" data-gallery="multiimages" data-toggle="lightbox"><img src="'. $pic .'" alt=""/></a>
<div class="liover"></div>
<a class="fav-icon" href="#"></a>
<a class="book-icon" href="details.html"></a>
</div>
</div>
<div class="col-md-8 offset-0">
<div class="itemlabel3">
<div class="labelright">
<img src="images/filter-rating-5.png" width="60" alt=""/><br/><br/><br/>
<img src="images/user-rating-5.png" width="60" alt=""/><br/>
<span class="size11 grey">18 Reviews</span><br/><br/>
<span class="green size18"><b>'. $price .'</b></span><br/>
<span class="size11 grey">Avg/Night</span><br/><br/><br/>
<form action="http://demo.titanicthemes.com/travel/details.html">
<button class="bookbtn mt1" type="submit">Book</button>
</form>
</div>
<div class="labelleft2">
<b>'. $country .'</b><br/><br/><br/>
<p class="grey">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nec semper lectus. Suspendisse placerat enim mauris, eget lobortis nisi egestas et.
Donec elementum metus et mi aliquam eleifend. Suspendisse volutpat egestas rhoncus.</p><br/>
<ul class="hotelpreferences">
<li class="icohp-internet"></li>
<li class="icohp-air"></li>
<li class="icohp-pool"></li>
<li class="icohp-childcare"></li>
<li class="icohp-fitness"></li>
<li class="icohp-breakfast"></li>
<li class="icohp-parking"></li>
<li class="icohp-pets"></li>
<li class="icohp-spa"></li>
</ul>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="offset-2"><hr class="featurette-divider3"></div>';
}
} else {
$dynamiclist = 'We Do Not Have Any Hotel Listed in This City';
}
?>
<?php echo $dynamiclist ?>
<?php include 'core/includes/listfooter.php'; ?>
你覆蓋'$ dynamiclist'每次迭代 – Andomar
和查詢包含'限制2'僅返回2行最多。 –
請建議如何避免這個錯誤我是新來的PHP ...想知道如果你可以編輯上面的代碼... –