iceblox Posted May 23, 2007 Share Posted May 23, 2007 Hi Guys, Im still a PHP newbie and i have a bit of script which allows me to edit stuff in my database but im trying to get it to work with a drop down box. So that when i use the page it will automatically select that option in the drop down. If that makes sense? I have this but it is selecting every option... here is the code... $manufacturer="<option>Select a Manufacturer</option>"; $result = $db->sql_query("SELECT * FROM manf ORDER BY manfname ASC"); while($row = $db->sql_fetchrow($result)) { $selected=""; if($row["manfid"]==$manfid) $selected = " selected=\"selected\""; $manufacturer.="<option$selected value=\"".$row["manfname"]."\">".$row["manfname"]."</option>"; } Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/52682-edit-form-drop-down-box-issues/ Share on other sites More sharing options...
AV1611 Posted May 23, 2007 Share Posted May 23, 2007 they are selected because you are telling them to be selected. Do you want them selected? (I think?) Quote Link to comment https://forums.phpfreaks.com/topic/52682-edit-form-drop-down-box-issues/#findComment-260097 Share on other sites More sharing options...
iceblox Posted May 23, 2007 Author Share Posted May 23, 2007 Sorry i probably didnt explain it well. The edit function is to edit a mobile phone review, the drop down box has the manufacturers in and the only one i want selected is the manufacturer that relates to the mobile being edited. Does that sound clearer? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/52682-edit-form-drop-down-box-issues/#findComment-260104 Share on other sites More sharing options...
AV1611 Posted May 23, 2007 Share Posted May 23, 2007 So, you want a drop down that lists all possible manufactures, but highlights only the one applicable to what the user has previously select? Quote Link to comment https://forums.phpfreaks.com/topic/52682-edit-form-drop-down-box-issues/#findComment-260115 Share on other sites More sharing options...
iceblox Posted May 23, 2007 Author Share Posted May 23, 2007 Yeah Quote Link to comment https://forums.phpfreaks.com/topic/52682-edit-form-drop-down-box-issues/#findComment-260117 Share on other sites More sharing options...
AV1611 Posted May 23, 2007 Share Posted May 23, 2007 Hi Guys, Im still a PHP newbie and i have a bit of script which allows me to edit stuff in my database but im trying to get it to work with a drop down box. So that when i use the page it will automatically select that option in the drop down. If that makes sense? I have this but it is selecting every option... here is the code... $manufacturer="<option>Select a Manufacturer</option>"; $result = $db->sql_query("SELECT * FROM manf ORDER BY manfname ASC"); while($row = $db->sql_fetchrow($result)) { $selected=""; if($row["manfid"]==$manfid) if($manfid==$_POST['MANFID']) //<---assumes selected on previous screen {$selected = " selected=\"selected\"";} else{$selected = "";} $manufacturer.="<option$selected value=\"".$row["manfname"]."\">".$row["manfname"]."</option>"; } Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/52682-edit-form-drop-down-box-issues/#findComment-260121 Share on other sites More sharing options...
iceblox Posted May 23, 2007 Author Share Posted May 23, 2007 ;O) Quote Link to comment https://forums.phpfreaks.com/topic/52682-edit-form-drop-down-box-issues/#findComment-260126 Share on other sites More sharing options...
rantsh Posted May 23, 2007 Share Posted May 23, 2007 Here comes CSS to the rescue adapt the following to your script <select> <option>Sony Ericcson</option> <option style="background-color:#FFFF00">Motorola</option> <option>Nokia</option> </select> Tested it on Opera 9+, FF2.0, IE7 and IE6, I'm guessing this is what you want... Quote Link to comment https://forums.phpfreaks.com/topic/52682-edit-form-drop-down-box-issues/#findComment-260130 Share on other sites More sharing options...
iceblox Posted May 23, 2007 Author Share Posted May 23, 2007 I Think ive got it! Cheers Guys! Quote Link to comment https://forums.phpfreaks.com/topic/52682-edit-form-drop-down-box-issues/#findComment-260131 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.