Insert Multiple Records not working - Insert Single Record works fine
After 2 days of struggling, this is driving me nuts, single insert works fine, but with multiple insert no records are added to the database. Please help.
<?php
// WA DataAssist Multiple Inserts
if (isset($_POST["btStem"])) // Trigger
{
if (!session_id()) session_start();
$WA_loopedFields = array("");
$WA_connection = $dbcASG2012;
$WA_table = "stem_stm";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "idspl_stm";
$WA_columnTypesStr = "none,none,NULL";
$WA_insertIfNotBlank = "test";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_dbcASG2012;
$WA_multipleInsertCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkMultiInsertLoopedFieldsExist($WA_loopedFields, $WA_multipleInsertCounter)) {
if ($WA_insertIfNotBlank == "" || WA_AB_checkLoopedFieldsNotBlank(array($WA_insertIfNotBlank), $WA_multipleInsertCounter)) {
$WA_fieldValuesStr = "".((isset($_POST["test"]))?implode(", ",$_POST["test"]):"") ."";
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
}
$WA_multipleInsertCounter++;
}
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
The form:
<form name="frmTest" id="frmTest" method="POST" action="<?php echo $editFormAction; ?>">
<table width="800">
<?php do { ?>
<tr>
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_rsTest){
?>
<td width="200">
<label>
<input type="checkbox" name="test[]" value="<?php echo $row_rsTest['id_spl']; ?>" id="test<?php echo $row_rsTest['id_spl']; ?>" />
<?php echo $row_rsTest['voornaam_spl']; ?> <?php echo $row_rsTest['tussenvgsl_spl']; ?> <?php echo $row_rsTest['achternaam_spl']; ?>
<?php if($row_rsTest['rookie_spl'] == 1) { ?> (Rookie)<?php } ?>
</label>
</td>
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<td> </td>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_rsTest && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_rsTest = mysql_fetch_assoc($rsTest);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
</tr>
<?php } while ($row_rsTest = mysql_fetch_assoc($rsTest)); ?>
</table>
<input name="btStem" type="submit" id="btStem" value="STEM" /></p>
<input type="hidden" name="MM_insert" value="frmTest" />
</form>