salhzmzm Posted February 13, 2008 Share Posted February 13, 2008 hi in my page there is this code: <select name="select_one" onchang="form1.submit()"> <option value="select">please select</option> <?php $row=mysql_query("select * from mytable order by id"); while ($rows=mysql_fetch_array($row)) { echo "<option value=$rows[id]>$rows[product]</option>; } ?> when the user is select the page submits and every thing apear ok, but I want the option that user had select it be the selected. I have problem the it the selected always the first option. so please help me. thanks. Link to comment https://forums.phpfreaks.com/topic/90869-need-help/ Share on other sites More sharing options...
haku Posted February 13, 2008 Share Posted February 13, 2008 <select name="select_one" onchang="form1.submit()"> <option value="select">please select</option> <?php $row=mysql_query("select * from mytable order by id"); while ($rows=mysql_fetch_array($row)) { echo "<option value=$rows[id]"; if($current_user_id == "$rows['id']) { echo "selected=\"selected\""; } echo ">$rows[product]</option>; } ?> note: I didn't fix your syntax errors. Link to comment https://forums.phpfreaks.com/topic/90869-need-help/#findComment-465696 Share on other sites More sharing options...
salhzmzm Posted February 13, 2008 Author Share Posted February 13, 2008 thanks for you're help. Link to comment https://forums.phpfreaks.com/topic/90869-need-help/#findComment-465717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.