gpt4 book ai didi

php - 在列表标签​​中的 while 循环中获取数据

转载 作者:行者123 更新时间:2023-11-28 06:26:55 25 4
gpt4 key购买 nike

while($recor1=mysql_fetch_assoc($res1))
{

?>
<ul>
<li class="col-md-3 col-sm-3"><a href="#"><div class="dest-list"><?php echo $recor1['sub_destination']; ?></div></a> </li>

</ul>
<div class="clearfix"></div>
<?php
}

它水平显示结果我想要垂直显示请给我解决方案

最佳答案

你的代码有很多问题,为什么你要为每个只有一个列表项的元素添加一个新列表,这没有意义。也不要在内联元素中添加 block 元素(a 中的 div)。此外,如果您将列表项放在彼此之下,那么为什么要添加 col-... 类?

<ul>
<?php while($recor1=mysql_fetch_assoc($res1)) {?>
<li class="">
<a href="#">
<?php echo $recor1['sub_destination']; ?>
</a>
</li>
<?php } ?>
</ul>

这为您提供了正确的 html 结构,然后您可以根据需要设置样式

关于php - 在列表标签​​中的 while 循环中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35218843/

25 4 0