How to populate a select field's options with database values and set the selected option using CodeIgniter's form_dropdown() [duplicate]
How can I populate my select field options using database data from my model and set the selected option based on the user's POST submission? This is my view <?php foreach ($cart as $item): ?> <tr> <td><?php echo $item['name']; ?></td> <td><?php echo $item['qty']; ?></td> <td><?php echo number_format($item['subtotal'],2); ?></td> <?php echo form_open_multipart('site/confirmed') ?> <?php $option = array(); foreach ($instructor as $r) { $option[$r->id] = $r->instructor; } echo "<td>" . form_dropdown('instructor', $option) . "</td>"; ?> This is my model 'isbn' => $items['name'], 'price' => $items
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.