Re: MySQL/PHP Associative Array Insert
| From: | Matt | Date: | Sun, 02 Feb 2003 14:29:55 +0000 |
| Subject: | Re: MySQL/PHP Associative Array Insert | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-133995@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "CDitty" <mail@redhotsweeps.com>
To: <php-general@lists.php.net>
Sent: Saturday, February 01, 2003 11:26 AM
Subject: [PHP] MySQL/PHP Associative Array Insert
> A co-worker is teaching me to move to the next level in php. I have
> started using associative arrays for my scripts, but I am having a problem
> using them to do an insert into MySQL. Can someone give me an example of
> how to do an insert to the database using these arrays? My array is
> this...$item['itemID']
The trick is to wrap array references in curly braces inside double quoted
strings.
// some data
$array['one'] = 'one';
$array['two'] = 'two';
// build the sql
$sql = "INSERT into table (field1,field2)
values('{$array['one']}','{array['two']}'";