Hey peeps,
I have a form which has checkboxes and textboxes.
Im trying to make a for each to duplicate all the data appart from one cell and make a new insert for every checkbox that has been checked:
for each checkbox that has been checked insert into the database. so it’ll look something like this
col1 col2 col3
1 2 3
1 2 5
1 2 9
Here how far its come:
[code=php]
<?php
echo ‘<p> post places: ‘ . $_POST[‘place’] . ‘</p>’;
$places_array = explode (‘,’ , $places);
echo ‘<p> places array: ‘ . print_r($places_array) . ‘</p>’;
foreach($places_array as $place_entry){
str_replace(“‘”, “”, $place_entry, $count);
echo $place_entry;
echo $count;
}
$insert = “INSERT INTO activities (`date`, `email`, `place`) VALUES (‘”.$daf.”‘,'”.$email.”‘,'”.$place_entry.”‘,'”)”;
$add_activity = mysql_query($insert);
if($add_activity == false) {
$error = mysql_error();
die(“<pre>”.$error.”n$insert</pre>”);
}
?>
This is what it prints out
post places: elm, fir
Array ( [0] => elm [1] => fir )
places array: 1
elm0 fir0
How would you make this work?