Re: Multi Files insert...

From: Date: Sat, 14 Sep 2002 15:48:31 +0000
Subject: Re: Multi Files insert...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116377@lists.php.net to get a copy of this message
Yes, I mean multi-files insert into a database. Here what I doing. I have this movie database that I keep track of all my media. I have a form that I use to add movies too. What I am wanting to do is add actor/actress to this db, but to another table. Since we all know that there are more one actor/actress. That is way I want to add multi files at once. I know it is done with a loop. So let say I want to add the following +-------------+---------+------------+ | fname | lname | title | +-------------+---------+------------+ | Bruce | Willis | 12 Monkeys | | Madeleine | Stowe | 12 Monkeys | | Brad | Pitt | 12 Monkeys | | Christopher | Plummer | 12 Monkeys | +-------------+---------+------------+ So that what I am trying. Chuck On 9/14/02 11:34 AM, "Matt" <mschroebel@epooch.com> wrote: >> 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 (#116377) next »