Forum Moderators: coopster

Message Too Old, No Replies

multiple select

         

Flolondon

11:38 am on Mar 21, 2006 (gmt 0)

10+ Year Member



please help. I have a multiple select drop down menu of say 4 items in the html page. I want to output what is selected to another php page and also put it to the database please help.

dreamcatcher

12:48 pm on Mar 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Flolondon,

You need to access the data as an array:

<select name="items[]" multiple>

Depends then on what you want to do. If you want to echo the contents to a single database table, you can implode the data. Or use a loop if you want seperate inserts.

Implode:

if (!empty($_POST['items']))
{
$data = implode(",", $_POST['items']);
}

or with a loop:

if (!empty($_POST['items']))
{
foreach ($_POST['items'] as $value)
{
echo $value;
}
}

dc

Flolondon

5:06 pm on Mar 26, 2006 (gmt 0)

10+ Year Member



ok thanks