I have a select on a form that updates the backend db ok. My problem is that when the form is displayed, it always shows the top record in the db and not the selected.
I've googled and read answers on stackoverflow among others but everything I try either doesn't work or breaks functionality.
$registrants points to a select on a registrants table. $affiliates points to a select on an affiliates table
Here is the select:
<select name="affiliate_id" class="form-control"> <?php foreach($affiliates as $display => $value) { ?> <option value='<?= $value['affiliate_id'] ?>' <?php if($registrants['affiliate_id'] == $value['affiliate_id']) { ?>selected='selected'<?php } ?>><?= $value['affiliate_name'] ?> </option> <?php } ?> </select>
Thanks for looking it over.
https://stackoverflow.com/questions/66610034/select-shows-the-top-record-in-the-db-and-not-the-selected March 13, 2021 at 12:06PM
没有评论:
发表评论