PHP: how to populate an input SELECT field with values from mysql DB table

I have mysql table MYTABLE with columns (id, value)

I have a form with an input dropdown menu and I would like to populate this (input SELECT) field with the values from MYTABLE.

In a few, if I click the SELECT field, I should see the list of “VALUES”. When selected a value, I should also take its own “ID” from MYTABLE…

How can I do?



In PHP try this :

<select class="form-control" id= "MYTABLE-dropdown" name="MYTABLE" required>     
<option value="">Select value</option>  
<?php foreach ($data as $key => $s) {?>   
<option value="<?=$s['id']?>"><?=$s['value']?></option>  
<?php } ?>