Re: Multi Files insert...

From: Date: Sat, 14 Sep 2002 15:34:56 +0000
Subject: Re: Multi Files insert...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116375@lists.php.net to get a copy of this message
> From: "Chuck PUP Payne" <payne@magidesign.com> > Sent: Saturday, September 14, 2002 11:10 AM > Subject: [PHP] Multi Files insert... > I am currently working a project were I need to add not one record but > several. How can I do that? Do I need to do a loop. How to do a loop to do > multi insertions. I know I sound like a fool, but I am still having problems > with loops. You're saying files, and records, so I assume you mean records in a db. Assuming mysql , you do something like this: $animals = array('cat','dog','puppy','kitten'); foreach ($animal as $type) { $sql = "Insert into table (animalType) values('$type'); $result = mysql_query($sql) or die(mysql_error()); $insertedID = mysql_insert_id(); } if you have a form with multiple values being selected, name the field with square brackets and php makes it an array (i.e. <input type="text" name="animals[]">) }

« previous php.general (#116375) next »