Consider the following code:-
$hostname = "localhost";
$username = "root";
$passowrd = "";
$database = "test";
$table = "customer";
# Database connection String
$con=mysqli_connect($hostname,$username,$passowrd,$database);
$result = mysqli_query($con, "SELECT ID,Name FROM $table");
$selectbox='<select name=\'register_number\' class=\'input-field\' id=\'registerNumber\' list=\'register_number\' placeholder=\'Select Register No\' >';
while ($row = mysqli_fetch_assoc($result)) {
$selectbox.='<option id="'. $row['ID'] .'" value="' . $row['ID'] . '">' . $row['Name'] . '</option>';
}
$selectbox.='</select>';
echo $selectbox;
Above code Corresponding HTML format is as following:-
<select name='register_number' class='input-field' id='registerNumber' list='register_number' placeholder='Select Register No' >
<option id="1" value="1">Rahim</option>
<option id="2" value="2">Karim</option>
<option id="3" value="3">Jamal</option>
<option id="4" value="4">Irfan</option>
</select>
Hope it work well. Happy Coding :)