Im trying to make an update form. In this update form is a dropdown list that is populated with value's from an mysql table. Now i got the expected values but i cannot get the right value to be selected (the one that belongs to the ID).
For example:
- co_id = the record for contacts, thats the one im updating.
- co_cs_id = the id of the company that belongs to the co_id, this is should be the selected value.
I got the following code:
echo "<td style width='30%'><select type='text' data-live-search='true' required data-live-search-style='startsWith' class='selectpicker form-control' name='co_cs_id' value='$contacts->co_cs_id'>";
$query = " SELECT cs_id, cs_name
FROM customers_suppliers
WHERE cs_status=0
ORDER BY cs_name";
$stmt = $db->prepare($query);
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
extract($row);
echo "<option value='{$cs_id}'>{$cs_name}</option>";
}
echo "</select>";
You can see that the company value is not the same.

