Re: array of unknown elements and insert query
| From: | Kevin Stone | Date: | Mon, 03 Feb 2003 20:37:29 +0000 |
| Subject: | Re: array of unknown elements and insert query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134181@lists.php.net to get a copy of this message | ||
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" <rusty_81@msn.com>
To: <php-general@lists.php.net>
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
>
>