sorry, I overlooked that you said an INSERT and not an UPDATE.
Foreach's are very simple, and extremely handy. Take this example:
In the above code I provided, the chexbox was named bla[]
This means on the processing script, you will have access to an array named bla. So you'd access it using $_POST['bla']['keys']
Where keys represents the array keys. 0, 1, 2, 3, etc. So in a foreach loop, you don't need to specify the keys part, it will loop through all of them.
foreach(array as $key => $value) is the format. Replace array with the array. $key will give you the value of the array key (0,1,2,3, etc) and $value will give you the value of that particular key. Within each execution of the foreach loop, you have access to one key and its corresponding value, so you run your insert statement each time the foreach is executed. So something like this
foreach($_POST['bla'] as $key => $value) {
$query = mysql_query("INSERT INTO table_name (field1) VALUES('" . $value . "')") or die(mysql_error());
}
Notice how I didn't use the $key. You don't need it, so you can simplify your foreach loop even more by doing
foreach($_POST['bla'] as $value) {
$query = mysql_query("INSERT INTO table_name (field1) VALUES('" . $value . "')") or die(mysql_error());
}
You can rename $key and $value to whatever you want. You just assign them in the foreach. Here's an example that would also work:
foreach($_POST['bla'] as $ar_val) {
$query = mysql_query("INSERT INTO table_name (field1) VALUES('" . $ar_val . "')") or die(mysql_error());
}
Hope this made sense.
Cgraz