I am trying to dynamically populate a drop down list in PHP and it is causing an endless loop and my browser to crash. I do not know how to correctly get it to show all the rows in one table but I would think this would be a relatively simple fix. The while loop might be throwing it off. Let me know if you need more information I am following this example but mine is written in PDO:
Dynamic drop down list using html and php
<h3>Company Listing</h3>
<select name='companies'>
<option value="">--- Select ---</option>
<?php
//gets user's info based off of a username.
$query = "SELECT business_name FROM Businesses";
try
{
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
}
//fetching all the rows from the query
$profileRow = $stmt->fetch();
while ($profileRow)
{
?>
<option value="<?php echo $profileRow['business_name']?>"><?php echo $profileRow['business_name']?></option>
<?php
}
?>
</select>
<p></p>