RE: [PHP] Q : HELP HTML forms parsed into an array for PHP
| From: | Ow Mun Heng | Date: | Tue, 17 Jun 2003 03:26:24 +0000 |
| Subject: | RE: [PHP] Q : HELP HTML forms parsed into an array for PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-151773@lists.php.net to get a copy of this message | ||
Thanks VERY VERY much. I was tearing my hair out.
Thanks for helping this newbie.
VERY much appreciated.
Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia
DID : 03-7870 5168
-----Original Message-----
From: John W. Holmes [mailto:holmes072000@charter.net]
Sent: Tuesday, June 17, 2003 10:34 AM
To: Ow Mun Heng
Cc: php-general@lists.php.net
Subject: Re: [PHP] Q : HELP HTML forms parsed into an array for PHP
Ow Mun Heng wrote:
> What I would like to do is to input multiple isbn numbers into a form, get
> PHP to parse it into an array so that I can build the SQL query for
multiple
> insert. Currently I'm able to perform single inputs, one at a time, which
is
> time consuming.
>
> I want to have a form<textarea name=isbn row=10 col=13> set up to get user
> input (multiline, each line separated by a carriage return - actually it's
> barcode is scanned in)
> eg : ISBN - 1-111-22222-1
> 1-111-22222-2
> 1-111-22222-3
>
> I would like to parse this data into PHP and get PHP to use a foreach loop
> (or a for loop) so that I can build up the $query to form ('isbn1')
> ('isbn2') ('isbn3').
>
> I'm trying to insert into mySQL a multiple value insert sort of like
>
> $query = insert into table values
> ('isbn1')
> ('isbn2')
> ('isbn3');
$isbn_string = "('" .
str_replace("\n","'),\n('",$_POST['isbn']) .
"')";
$query = "INSERT INTO table VALUES $isbn_string";
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
PHP|Architect: A magazine for PHP Professionals – www.phparch.com