gpt4 book ai didi

php - 如何使用 php 在列表中回显结果

转载 作者:行者123 更新时间:2023-12-01 00:08:40 25 4
gpt4 key购买 nike

我想使用 php 在列表中打印 sql 结果。

<?php 
$query="select name from plant ";
$q=mysqli_query($con,$query)or die("Could Not Perform the Query");
while ($row = $q->fetch_assoc()) {
$hh=$row['name'];
}
?>
<ul id="myUL">
<li><a href="#"><?php echo $hh ?></a></li>
</ul>

喜欢:-

.芒果

.苹果

.香蕉

最佳答案

<?php 
$query="select name from plant ";
$q=mysqli_query($con,$query)or die("Could Not Perform the Query");
echo "<ul id="myUL">";
while ($row = $q->fetch_assoc()) {
echo "<li> <a href='#'>".$row['name']."</a></li>";
}
echo "</ul>";
?>

关于php - 如何使用 php 在列表中回显结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54513379/

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