ucohockey
asked on
How to show a selected option in a dropdowm from mysql
I have a select dropdown that is populated from a mysql table which is working great. The dropdown is on a update profile page so how do I populate the dropdown from one table but then also get the value that was stored in a different table and show it as selected in the dropdown.
Here is the code for the dropdown.
Here is the code for the dropdown.
<select name="type" id="type" data-placeholder="type" class="form-control form-control-select2 select2-hidden-accessible" data-fouc="" tabindex="-1" aria-hidden="true" required>
<option value="" selected>Type</option>
<?php
$type = $link->query( "SELECT * FROM type" );
while ( $rows = $vertical->fetch_assoc() ) {
$type = $rows[ 'type' ];
echo "<option value ='$type'>$type</option>";
}
?>
</select>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window