RE: [PHP] Multiple insert question

From: Date: Mon, 11 Sep 2000 23:12:37 +0000
Subject: RE: [PHP] Multiple insert question
Groups: php.general 
Request: Send a blank email to php-general+get-16251@lists.php.net to get a copy of this message
basically, you'll probably have to use a while loop to insert the information changing the vars every time. ie. while ($row = mysql_fetch_row($resultset)) { list($name) = $row; $isql = "insert into table (field1,field2,field3,field4,field5,field6) values ('$name','$value1','$value2','$value3','$value4','$value5')"; mysql_db_query($dbname,$isql,$db); } provided you've already set your query and are bringing back the name from table1, this method will set the result into $name, then your values would be set either from a different query or something... and slap them all into a new table. hope this helps. Dave Fudge Developer ----------------------------- "...so let your children run wild and free. Because as the old saying goes, 'Let your children run wild and free...'" - Homer J. Simpson -----Original Message----- From: PHPlist [mailto:phplist@webbcite.com] Sent: Monday, September 11, 2000 6:50 PM To: php-general@lists.php.net Subject: [PHP] Multiple insert question I have a MySQL database that I am pulling information from. I have one table that I am pulling a list of names. I would like to insert the names plus other information into a different table. The problem is that the values for the name will be different but the information I am adding will have the same variable name for each name. Here is a visual: name1 value1 value2 value3 value4 value5 name2 value1 value2 value3 value4 value5 name3 value1 value2 value3 value4 value5 name4 value1 value2 value3 value4 value5 name5 value1 value2 value3 value4 value5 So my problem is that I have 5 different variable names for each name#. Each name# and associated values will be a row in the new table. How do I insert all five "rows" at one time? Would I just do 5 different insert statements? One for each "row"? Won't the values for the variables be overwritten on each row? Are there any relatively easy ways to accomplish this? I'm your basic newbie... My brain is starting to leak....I need some help... TIA Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#16251) next »