![]() |
Explode for selected - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Explode for selected (/showthread.php?tid=69336) |
Explode for selected - googlemy - 11-06-2017 Hi all, I have trouble on this code, In DB "planCurrencies" = "1,2,3,4" PHP Code: <select class="select2" name="currency[]" style="width: 100%" multiple="multiple" data-placeholder="Choose"> This code already show all currencies but selected currency not working, Thanks you RE: Explode for selected - pravins - 11-06-2017 $cid is array in your case, so the <option> selected will be like this Code: <option value="<?php echo $c->ID; ?>" <?php echo in_array($c->ID, $cid) ? "selected":"" ?>><?php echo $c->currencyCode; ?></option> I hope this works for you RE: Explode for selected - googlemy - 11-06-2017 (11-06-2017, 10:43 PM)pravins Wrote: $cid is array in your case, so the <option> selected will be like this Oh man!! it's really work! Thanks you so much!! |