I want to save each row by getting the ID of selected value in the dropdown like this:
This is supposed to be a comment, but i have a low reputation here Hi Khan i do not really understand what you mean. A dropdown is basically a select option. The attribute "value" is what gets posted as the selected value. To save the value, simply have this:
$selected_value = mysqli_real_escape_string($connection, $_POST['name_of_dropdown_from_html_form']);
To get the value on an update form, do this:
<select id="id_of_field" name="name_of_field" class="form-control">
<?php
#i assume your select dropdown list is from a database.
#SO in that table, we have two columns, id_of_table and list_type.
#For example a list of different types of cars,
#id(1) and list_type(BMW).
#SO now we check if the id of the car is in the current dropdown list
$list = $class->get_list();
foreach ($list as $key => $value) {
if ($value['id_of_table'] == $value['list_type']) {
$selected = "selected='selected'";
echo "<option value=\"{$value['id_of_table']}\" {$selected}>{$value['list_type']}</option>";
} else {
echo "<option value=\"{$value['id_of_table']}\">{$value['list_type']}</option>";
}
}
?>
</select>
try and integrate this with your project and let me know what you get