我正在做一个下拉菜单,其中包含数据库中的项,使用PHP for each循环,代码只生成一个下拉项,但数据库有超过1行,那么问题在哪里?
表:
-------------------------------------
| id | Address | text |
-------------------------------------
| 1 | foo | 5 |
-------------------------------------
| 2 | bar | 13 |
-------------------------------------下拉列表仅包含foo。
<?php foreach($items as $newitem){?>
<div class="dropdown-menu" style="height:29vh; width:30vh;"aria-labelledby="myInput">
<a class="dropdown-item" href="#"><?=$newitem['name'];?></a>
</div>
<?}?>发布于 2021-07-30 18:23:52
您使用哪种sql查询从数据库中获取数据?如果您使用的是mysqli_fetch_array(),请尝试使用mysqli_fetch_assoc()。
https://stackoverflow.com/questions/68595482
复制相似问题