Re: Multiple Inserts With PHP

From: Date: Wed, 18 Oct 2000 20:46:08 +0000
Subject: Re: Multiple Inserts With PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-20979@lists.php.net to get a copy of this message
Assuming you have a MySQL table like: id INT UNSIGNED NOT NULL AUTO_INCREMENT value CHAR(1) you could do something like this: -------------------------------------------------- $theAry = array("A", "B", "C"); reset($theAry); while( list(, $value) = each($theAry) ) { mysql_query("INSERT INTO mytable VALUES (0, '$value')"); } -------------------------------------------------- -philip In article <4.3.2.7.2.20001018095048.01ddb450@freewolf.net> you write: >Greetings Folks, > >I have a form with a drop down list. The user can select multiple options >from the list and of course the options get plugged into an array. > >Now what I want to know is how to take the information from the array and >make multiple inserts into a MySQL table. > >So I would have an array with the following values. > >A >B >C > >And I want each to insert as a different record in a table so in the table >it would be inserted as > >id value >1 A >2 B >3 C > >Now I am suspecting that I need to use some sort of do...while or for loop >loop that would pull the first value from the array and run an insert >statement in the DB, then increment the place the array by one and run >again. But my brain is not figuring out how exactly this would be written. >Can anyone help me out?

« previous php.general (#20979) next »