如何在php下拉列表中使用选定的值? [重复]

I am using following code for dropdown in php

$iname=$row['name'];

// Write query for Items dropdown.
$iquery = "SELECT * FROM items";

// Execute it, or return the error message if there's a problem.
$iresult = mysqli_query($con, $iquery) or die(mysql_error());
$edropdown = "<select name='epin' style=\"height:37px; width:222px;\">";
while($erow = mysqli_fetch_assoc($iresult))
{
    $edropdown .= "
<option value='{$erow['name']}'>{$erow['name']}</option>";
}
$edropdown .= "
</select>";
echo $edropdown;

I am using this code in an edit form. I want to use selected value ($iname) in the dropdown. How can set selected value in this code. Regards

</div>

if you want to compare this value $iname with your options, use below code:

$edropdown .= "
<option value='{$erow['name']}' ({$erow['name']}==$iname)?'selected':''>{$erow['name']}</option>";