Re: Multi Files insert...

From: Date: Sat, 14 Sep 2002 16:02:19 +0000
Subject: Re: Multi Files insert...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116380@lists.php.net to get a copy of this message
On 9/14/02 11:50 AM, "John Holmes" <holmes072000@charter.net> wrote: >> 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. > > Assumming a database...you can use this form of insert and do it in one > query: > > INSERT INTO table (col1, col2, col2) VALUES > (val1,val2,val3),(val11,val22,val33),(val111,val222,val333) > > And insert as much as you want. > > ---John Holmes... > So if I understand right I can do this... +-------------+---------+------------+ | fname | lname | title | +-------------+---------+------------+ | Bruce | Willis | 12 Monkeys | | Madeleine | Stowe | 12 Monkeys | | Brad | Pitt | 12 Monkeys | | Christopher | Plummer | 12 Monkeys | +-------------+---------+------------+ INSERT INTO actormovie (fname, lname, title) VALUES ($fname1,$lname1,$title1),($fname2, $fname, $title2),($fname3,$lname3,$name) Cool so I could have a form with mutli values to input. How would do with an if or while statement. Would this be a way? $sql = "INSERT INTO actormovie (fname, lname, title) VALUES (\"$fname\", \"$lname\", \"$title\")"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $sql = $row[$fname], $row[$lname], $row[$title]; } Or am I on the wrong path? Chuck

« previous php.general (#116380) next »