I am trying to insert multiple rows using foreach, with no luck. I am able to insert the rows i want, however all the rows have the same value (that of the last row). This is the script i'm using:
foreach($_POST as $key=>$val) {
$contaminant = $_POST['contaminant'];
//$gac_value = $_POST['gac_value'];
$ms_conc0 = $_POST['ms_conc0'];
$ms_conc1 = $_POST['ms_conc1'];
$ms_conc2 = $_POST['ms_conc2'];
$ms_conc3 = $_POST['ms_conc3'];
$ms_conc4 = $_POST['ms_conc4'];
$query = "INSERT INTO qgra (id, contaminant, gac_value, ms_conc0, ms_conc1, ms_conc2, ms_conc3, ms_conc4)
VALUES ('','$contaminant', '$gac_value', '$ms_conc0', '$ms_conc1', '$ms_conc2', '$ms_conc3', '$ms_conc4') ";
$result = mysql_query($query) or die(mysql_error()); }
echo "<br><br> Worked?! ";
Tried using foreach($_POST as $key=>$val) { } as well but was that wayyyy off.
Any ideas where im going wrong?
Thanks