bluedollar
Programmer
I have a drop down box that supports multiple selections:
#======================================================================
function dropdownboxmul($SQL,$desc,$name,$form,$id) {
$result = mysql_query($SQL) or die("bad query '$SQL' : ".mysql_error());
echo '<P> '.$desc.' ';
if ($form != ""
{
echo '<SELECT name="'.$name.'" onChange="document.'.$form.'.submit();">';
}
else {
echo '<SELECT name="'.$name.'" MULTIPLE size="3">';
}
while ($res = mysql_fetch_row( $result )) {
foreach($res as $field => $value) {
if ($value == $id) {
echo '<OPTION SELECTED value="'.$value.'"> '.$value.'';
}
else {
echo '<OPTION value="'.$value.'"> '.$value.'';
}
}
}
echo '</P></select>';
}
#======================================================================
I use this box in a form and call it as follows:
$this->obconnect->dropdownboxmul($SQL,"","paper_id","",''.$result.'');
This works fine, displays on the page and users can make multiple selections. However when the form is submitted, the script that is called, when I do a echo('$paper_id') only the last item selected is displayed. eg.
user selects
3
4
7
8
9
result of echo('$paper_id') = 9
Does anyone know how to display all the items that have been selected?
Any help Would be greatly appreciated.
Thanks
Dan
#======================================================================
function dropdownboxmul($SQL,$desc,$name,$form,$id) {
$result = mysql_query($SQL) or die("bad query '$SQL' : ".mysql_error());
echo '<P> '.$desc.' ';
if ($form != ""

echo '<SELECT name="'.$name.'" onChange="document.'.$form.'.submit();">';
}
else {
echo '<SELECT name="'.$name.'" MULTIPLE size="3">';
}
while ($res = mysql_fetch_row( $result )) {
foreach($res as $field => $value) {
if ($value == $id) {
echo '<OPTION SELECTED value="'.$value.'"> '.$value.'';
}
else {
echo '<OPTION value="'.$value.'"> '.$value.'';
}
}
}
echo '</P></select>';
}
#======================================================================
I use this box in a form and call it as follows:
$this->obconnect->dropdownboxmul($SQL,"","paper_id","",''.$result.'');
This works fine, displays on the page and users can make multiple selections. However when the form is submitted, the script that is called, when I do a echo('$paper_id') only the last item selected is displayed. eg.
user selects
3
4
7
8
9
result of echo('$paper_id') = 9
Does anyone know how to display all the items that have been selected?
Any help Would be greatly appreciated.
Thanks
Dan