根据SQL查询在下拉列表html中设置默认项?

Would this be the proper way to add a default value to a drop down menu it HTML?

$vendor_name is determine by a query to get an array of results; that is iterated through to create table rows in HTML. So this value changes dependent on the iteration.

<option value='$vendor_name'>$vendor_name</option>";
while($row = mysqli_fetch_array($result))
{
    echo "<option value='".$row['vendor_id']."'>".$row['name']."</option>";
}

When I attempt this it shows the default value; however, the table that is being created here is used to update an SQL table. If i change any other value in the row related to the $vendor_name without changing the $vendor_name it will not update. Is this because I set the default value?

Below is the correct way of setting default item in DropDown with PHP.

<?php
while ($row = mysqli_fetch_array($result)) {
  $selected = '';
  if ($vendor_name == $row['name']) {
    $selected = ' selected';
  }
  echo "<option value='" . $row['vendor_id'] . "'" . $selected . ">" . $row['name'] . "</option>";
}
?>
`<?php

while ($row = mysqli_fetch_array($result)) {

echo "<option value='" . $row['vendor_id'] . "'" .( ( $vendor_name == $row['name'])? 'selected': '' ) . ">" . $row['name'] . "</option>"; } ?>