I am in need of a way to populate a drop down list (I believe it is called a Select) with a SQL Server query.
I want to populate the list with the results of Select storeName from storeinfo
which would return roughly 30 results and I would want these results to be displayed in the Select at page load.
How is this achieved through php? Or since I Need this done on page load would I have to use some sort of JQuery/Ajax request to accomplish?
I see this can populate my select list, but how to do it on page load?
<select name="store">
<?php
$sql = mysqli_query($connection, "SELECT storeName FROM stores");
while ($row = $sql->fetch_assoc()){
echo "<option value=\"store1\">" . $row['storeName'] . "</option>";
}
?>
</select>