Something like..

$query = "INSERT INTO tablename (fieldname) VALUES";
foreach ($_POST['listbox'] as $key => $val) {
   $values[] = "('$val')";
}
$query .= implode(',', $values);
$result = mysql_query($query);

This is assuming all your listbox values go into the same table column.

-Kevin


----- Original Message -----
From: "Sunfire" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 03, 2003 1:15 PM
Subject: [PHP] array of unknown elements and insert query


> hi..
>
> i have an array (not written in code yet) but it is from a multiple select
> listbox and i want to use the elements in the array in an insert query..
and
> dont know how that works...
> (i wont know how many elements there will be on the insert)..the array
> elements will need to be put in 1 field on the table as a single string
>
> anybody have example code for that??
>
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to