im using script for dynamic adding row for table
but on of the option in my row should be in select from my database`
var items = 0;
function addItem(){
items++;
var html = "<tr>";
html += "<td>" + items + "</td>";
html += "<td><input class='form-control' name='machine[]' placeholder='machine'><td>";
html += "<td><input class='form-control' name='meterstart[]' placeholder='meter start'><td>";
html += "<td><input class='form-control' name='meterend[]' placeholder='meter end'><td>";
html += "</tr>";
document.getElementById("tbody").insertRow().innerHTML = html;
}
`
this is my script
`
var items = 0;
function addItem(){
items++;
var html = "<tr>";
html += "<td>" + items + "</td>";
html += "<select class="form-control" name="machine" required="true">
<option selected hidden>select machine</option>
<?php
if($machine_list_result->num_rows > 0){
while($mac = $machine_list_result->fetch_array()){
?>
<option value="<?php echo $mac['id']; ?>" ><?php echo $mac['model']." -".$mac['machinenumber']; ?></option>
<?php
}
}
?>
</select>";
html += "<td><input class='form-control' name='meterstart[]' placeholder='meter start'><td>";
html += "<td><input class='form-control' name='meterend[]' placeholder='meter end'><td>";
html += "</tr>";
document.getElementById("tbody").insertRow().innerHTML = html;
}
`
this what im trying to achieve