I am able to populate a select drop down with all entries from the database but stuck where the already set value is not able to show or shows as a duplicate. i searched on here and found two similar questions but their answers did not help me. my code below
connect.php is included which has all the database connect information
<?php
include 'connect.php';
$qry=mysql_query("SELECT * FROM experts", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
?>
<select name="expert" id="expert">
<option value="<?php echo $row['expert']; ?>"><?php echo $row['expert']; ?> </option>
<?php
while($row=mysql_fetch_array($qry))
{
echo "<option value='".$row['expert']."'>".$row['expert']."</option>";
}
?>
</select>
the problem with this is it includes a duplicate entry as well as the selected entry. i know i need to add an if statement to remove the selected entry but not sure how.
PHP MySQL Drop Down Box Populate Selected Value seems to have my answer but i don't seem to be able to use the example to suit my code as its worded differently.