从HTML / PHP中的SQL数据库获取匹配的索引值?

I want to know how to echo value in dropdown in php? Suppose I am getting $Selectedcurrency = "Euro"; from the database.

And below is my dropdown:

<select name='currencies' id="currencies"  onchange="setForm(this.value)">
 <option value=''>Kindly Select The Currecy</option>
 <option value='USD'>USD</option>
 <option value='AUD'>AUD</option>
 <option value='EURO'>EURO</option>
</select>

I want the dropdown will show the matched saved value comming from the database ie: $Selectedcurrency = "Euro";

Any idea or suggestions would be welcome.

You can use selected along with if statements

TRY THIS:

<?php
$Selectedcurrency = 'EURO';
?>

<select name='currencies' id="currencies"  onchange="setForm(this.value)">
 <option value='' <?php if($Selectedcurrency == '') { echo "selected"; } ?>>Kindly Select The Currecy</option>
 <option value='USD' <?php if($Selectedcurrency == 'USD') { echo "selected"; } ?>>USD</option>
 <option value='AUD' <?php if($Selectedcurrency == 'AUD') { echo "selected"; } ?>>AUD</option>
 <option value='EURO' <?php if($Selectedcurrency == 'EURO') { echo "selected"; } ?>>EURO</option>
</select>

The ternary operator here will be more elegant from my point of view.

<select name='currencies' id="currencies"  onchange="setForm(this.value)">
     <option value=''>Kindly Select The Currecy</option>
     <option <?php echo (($Selectedcurrency !== "USD") ?: "selected"); ?> value='USD'>
      USD
     </option>
     <option <?php echo (($Selectedcurrency !== "AUD") ?: "selected"); ?> value='AUD'>
      AUD
     </option>
     <option <?php echo (($Selectedcurrency !== "EURO") ?: "selected"); ?> value='EURO'>
      EURO
     </option>
</select>