dropdown menu items with php foreach

Solution for dropdown menu items with php foreach
is Given Below:

I’m working on a dropdown menu that has items from the database using PHP for each loop The code is making only one dropdown item but the database have more than 1 rows so where is the problem?


| id | Address | text |
| 1  | foo     | 5    |
| 2  | bar     | 13   |

the dropdown contains [ foo ] only.

    <?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>

which sql query are you using to get data from database? if you are using mysqli_fetch_array() then try mysqli_fetch_assoc().