Re: Q : HELP HTML forms parsed into an array for PHP

From: Date: Tue, 17 Jun 2003 02:34:21 +0000
Subject: Re: Q : HELP HTML forms parsed into an array for PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-151772@lists.php.net to get a copy of this message
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

« previous php.general (#151772) next »