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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -