I have some code (seen below) to perform multiple inserts, however it doesnt work.
for ($i = 0;$i < $choice;$i++) {
mysql_query ("INSERT INTO options (choice) VALUES ('$choice')"); }
What are you keeping in "$choice"?
If $choice = 5, then it's going to insert the value 5 into your table 5 times..?
Is that what you want?
The query should really be:
mysql_query ("INSERT INTO options (choice) VALUES ('$i')");
I want the changing variable $i to be inserted N number of times (where N is $choice).
I think I will need a FOREACH thing but I aint too sure
I have a similar task. Say if I am entering contact information for a group of people into a table (form). Each row has 'name' and 'email'. The table could have 10 rows, but I am just entering 5 people. How do I insert the data into database?
Paul
this may get you in the right direction, this is how i delete numerous selections based on a checkbox array in the form named id[]
while (@list($key, $value) = each($id)) { $query = "delete from table where id = $value;"; $result = mysql_query($query) or die(mysql_error()); }
Thanks. I will give it a try. Will let you know if it works.