<form name="" action="" method="">
Notice the "[ ]" at the end of the select box name, this prompts php to
treat the values as an array.
<select name="options[]" size="10" multiple>
<?
$query = "select value1,value2 from table";
if($result=mysql_query($query)){
while ($myrow = mysql_fetch_row($result)) {
print "<option value='$myrow[0]'>$myrow[1]";
}
}
?>
</select>
<input type="submit" value="submit">
</form>
When the form is submitted I fire this code
$mycount = count($options); // get the number of elements in the
array (selected in the drop down)
while($mycount){// cycle through the array decrementling your
counter var ($mycount) untill you have inserted all of the values.
$mycount--;
mysql_query("INSERT INTO table (value1,value2) VALUES
($value1,$options[$mycount])");
}
I hope this helps, it works perfectly for me and uses less code than
other examples I have seen.
> On Monday, January 28, 2002, at 10:41 AM, Simos Varelakis wrote:
>
>> A php form contains a listbox (named foolist) with n Items which
>> can be
>> multiple selected and form posted to
>> results.php how can results.php determine which items were selected
>> in order
>> to add all the items in a Mysql table ???
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]