close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Insert Multiple Records not working - Insert Single Record works fine

Thread began 2/18/2012 4:26 am by henk303241 | Last modified 2/21/2012 9:59 am by Jason Byrnes | 776 views | 1 replies |


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.

// 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());
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 { ?>
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
if($RepeatSelectionCounterBasedLooping_1 || $row_rsTest){
<td width="200">
<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) { ?>&nbsp;(Rookie)<?php } ?>
} // RepeatSelectionCounter_1 Begin Alternate Content
<?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 End Loop
<?php } while ($row_rsTest = mysql_fetch_assoc($rsTest)); ?>
<input name="btStem" type="submit" id="btStem" value="STEM" /></p>
<input type="hidden" name="MM_insert" value="frmTest" />

Sign in to reply to this post

Jason ByrnesWebAssist

with a multiple record insert, do not set the checkbox as an array:

instead of:


Add the checkbox to your page, then add a repeat region around it, then add the multiple insert behavior

Make sure that you bind the ceckbox repeated field to one of the columns, the checkbox is uses as a trigger for whether to insert that value or not,

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...