Jump to content

show the Selected options in the edit page (help please)


Darkwoods

Recommended Posts

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

 

 

 

 

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";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.