php - Selecting html select list from sql database -
i kind if have interesting question. i'm trying prefill edit form in codeignitert. have of values coming through database, select box giving me few issues. want highlight had selected not erase list , fill in selected...if makes sence.
here html
<?foreach($info $row) :?> <select multiple="multiple" class="multi" name="wgenre[]"> <option value="action/adventure">action/adventure</option> <option value="angst">angst</option> <option value="crime">crime</option> <option value="drama">drama</option> <option value="family">family</option> <option value="fantasy">fantasy</option> <option value="friendship">friendship</option> <option value="general">general</option> </select> <?endforeach;?>
i've tried couple of things. have tried putting list in inner loop , trying select comes through echo, threw me errors. individual if statement each item, shortened list above , have , seems unnecessary amount of code.
if helps, when echo entire list comes string, this. fantasy friendship general , have full text searching enabled.
thank in advance help! :)
<select multiple="multiple" class="multi" name="wgenre[]"> <option value="action/adventure" <?php if(in_array('action/adventure',$info)) echo 'selected="selected"';?>>action/adventure</option>
do same all
Comments
Post a Comment