gpt4 book ai didi

php - 查询仅返回所有行意图中的 1 行

转载 作者:行者123 更新时间:2023-11-30 00:51:30 25 4
gpt4 key购买 nike

我被下面的代码卡住了...根据我的理解,下面的代码应该显示在我的数据库中创建的所有行数据...但是我只得到 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'; ?>

最佳答案

您有两个问题

您的数据库查询仅限于 2 项(尽管这并不能解释您目前遇到的 1 项问题)

删除 LIMIT 2 将解决此问题

其次

 $dynamiclist    = '<div class=/"offset-2/">

“=”号表示您每次将其设置为内容。

这很好,除非你在 while 循环之外回显它

在 while 循环中回显它或将其更改为

$dynamiclist    .= '<div class=/"offset-2/">

注意 .= -> 将项目添加到字符串末尾。

希望有帮助

关于php - 查询仅返回所有行意图中的 1 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20933226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com