Multiple MySQL INSERT into loop

From: Date: Thu, 07 Feb 2008 07:07:22 +0000
Subject: Multiple MySQL INSERT into loop
Groups: php.general 
Request: Send a blank email to php-general+get-268845@lists.php.net to get a copy of this message
I'm working on this, and am not sure how the variable syntax needs to be here. This is what I have done manually. //BEGIN EXAMPLE mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_1', '$entry_1', '$name_1')"); mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_2', '$entry_2', '$name_2')"); mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_3', '$entry_3', '$name_3')"); //END EXAMPLE I'd like to put this into a loop, so that the variable that are being defined as the VALUES change as needed. //BEGIN EXAMPLE while ($i<16) { $i++; mysql_query ("INSERT INTO testimonials (id,quote,name) VALUES ('$id_1', '$entry_1', '$name_1')");)"); } //END EXAMPLE What I'm trying to figure out, is exactly how I need to format my entry within the VALUES section, so that it will change based on the value of $i.

« previous php.general (#268845) next »