php - Select current option in select menu -
lets $cat 5, want have forum id 5 selected wont. have forum id 5. shouldn't work?
<select name="category" id="category"> foreach($db->query("select name forums order disp_position asc") $row) {    if ($cat == $row['id']) {       echo '<option value="'.$row['id'].'" selected>'.$row['name'].'</option>';    } else {       echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';    } } </select> 
you should add id field in select.
select id, name forums order disp_position asc 
Comments
Post a Comment