Darkwoods Posted February 19, 2009 Share Posted February 19, 2009 hello i have a multitiple dropdown box in the edit page and i would like to how the selected options in the edit page here is the code: echo '<input type=hidden name="type_specialitydoc" value="multiselect"> <select size = "15" id="value_specialitydoc" name="value_specialitydoc[]" multiple > '; $dbquery2 = mysql_query("SELECT * FROM specialty_categories"); while ($dbrow2 = mysql_fetch_array($dbquery2)) { $id1 = $dbrow2['id']; $catname = $dbrow2['catname']; /* echo '<option style="font-weight:bold; color:#CCCCCC" value="'. $id1 .'"disabled="disabled">-'. $catname . '</option>'; */ echo '<optgroup label="'. $catname . '">'; $dbquery = mysql_query("SELECT * FROM specialty where speccat = $id1 ORDER BY name;"); while ($dbrow = mysql_fetch_array($dbquery)) { $id = $dbrow['id']; $name = $dbrow['name']; echo ' <option value="' .$id .'"> ' . $name .'</option> '; } } echo '</SELECT>'; thats how my database looks like: Table1: Maintable Column: id, field1, field2, SPECIALTY <<< (the values of the id from table specialty .catvalue) Table2: Specialty Column: id, name, catvalue Table3: Specialty_categories Column: id, catname Link to comment https://forums.phpfreaks.com/topic/145906-show-the-selected-options-in-the-edit-page-help-please/ Share on other sites More sharing options...
phpdragon Posted February 19, 2009 Share Posted February 19, 2009 while ($dbrow = mysql_fetch_array($dbquery)) { $id = $dbrow['id']; $name = $dbrow['name']; echo "<option value='$id'"; if (($_POST['id']) == ($id)) { echo "selected"; } echo "> $name</option>\n"; } Link to comment https://forums.phpfreaks.com/topic/145906-show-the-selected-options-in-the-edit-page-help-please/#findComment-766036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.