suppose i make a dropdown menu having value 1, 2, 3, 4, 5, one option can be selected, and selected option is stored in database. now i create an edit page, how do i display the selected value in the menu and other values in dropdown, for example, Menu is like Select One 1 2 3 4 5 and i select 3, this 3 is stored in database, now on the edit page i want to show 3 as already selected, something like that.. <select name="select_thing"> <option value="1">1</option> <option value="2">2</option> <option value="3" selected>3</option> <option value="4">4</option> <option value="5">5</option> </select> HTML: I will be very thankful, if someone could help by explaining how do i make option 3 as selected.. eg. how i know option 3 is selected and stored in db.
Fetch rows of table to an array and use a foreach for displaying them. like this : foreach($rows as $row) echo "<option value='{$row[name]}'>{$row[name]}</option>"; PHP:
urm, did you actually read that post ??? @op can you post the code that draws the form to begin with ... it's quite easy only I can't guess your database schema
Here is some code (hope I understand your question): ?><select name="select_name"><? $db->query("SELECT * FROM users WHERE id={$_SESSION['user']['ID']}"); if($db->next_record()) for($i=1;$i<7;$i++){ ?>option value="<?=$i;?>" <?=($db->f('value')==$i)?:"selected":"";?>><?=$i;?></option><? } ?></select><? PHP: This is quite abstract example, hope it is clear and helpful.