Tried a blank page - still no work
As a follow up to this I thought I would try the behaviour on a blank page and the problem is the same.
The behaviour deletes the corresponding records that match the MANUAL_ID key in the relational table. I'm convinced this has to do with no value being passed from the checkbox, however if I view the source the value appears correct. Here is my page:
<?php require_once('Connections/boomcms.php'); ?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_boomcms, $boomcms);
$query_manual = "SELECT * FROM manuals WHERE MANUAL_ID = 6";
$manual = mysql_query($query_manual, $boomcms) or die(mysql_error());
$row_manual = mysql_fetch_assoc($manual);
$totalRows_manual = mysql_num_rows($manual);
mysql_select_db($database_boomcms, $boomcms);
$query_chapters = "SELECT * FROM chapters";
$chapters = mysql_query($query_chapters, $boomcms) or die(mysql_error());
$row_chapters = mysql_fetch_assoc($chapters);
$totalRows_chapters = mysql_num_rows($chapters);?>
<?php
// WA DataAssist Manage Relational Table 1
if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
$WA_arrayOrFieldList = 1;
$WA_joinLoopedField = "CHAP_ID";
$WA_loopedField = "WADA_RepeatID_CHAP_ID";
$WA_connection = $boomcms;
$WA_table = "map_mc";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_masterKeyField = "MANUAL_ID";
$WA_masterKeyType = "none,none,NULL";
$WA_masterKeyValue = "".$row_manual['MANUAL_ID'] ."";
$WA_masterKeyComp = "=";
$WA_joinedKeyField = "CHAP_ID";
$WA_joinedKeyType = "none,none,NULL";
$WA_joinedKeyComp = "=";
$WA_fieldNamesStr = "MANUAL_ID|CHAP_ID";
$WA_columnTypesStr = "none,none,NULL|none,none,NULL";
$WA_appliedString = "";
$WA_appliedList = array();
$WA_valuesList = array();
$WA_connectionDB = $database_boomcms;
mysql_select_db($WA_connectionDB, $WA_connection);
if ($WA_arrayOrFieldList == 0) {
$WA_loopedValues = $_POST[$WA_joinLoopedField];
for ($v=0; $v<sizeof($WA_loopedValues); $v++) {
$WA_fieldValues = "^MASTERID^" . "|" . "^JOINID^";
$WA_valuesList[] = array($WA_loopedValues[$v], $WA_fieldValues);
$WA_appliedString .= "^" . $WA_loopedValues[$v] . "^";
$WA_appliedList[] = $WA_loopedValues[$v];
}
}
else if ($WA_arrayOrFieldList == 1) {
$WA_mrtLoopCounter = 0;
while (WA_AB_checkLoopedFieldsExist(array($WA_loopedField), $WA_mrtLoopCounter)) {
if (WA_AB_checkLoopedFieldsNotBlank(array($WA_joinLoopedField), $WA_mrtLoopCounter) && WA_AB_getLoopedFieldValue($WA_loopedField, $WA_mrtLoopCounter) == WA_AB_getLoopedFieldValue($WA_joinLoopedField, $WA_mrtLoopCounter)) {
$WA_fieldValues = "^MASTERID^" . "|" . "^JOINID^";
$WA_valuesList[] = array(WA_AB_getLoopedFieldValue($WA_loopedField, $WA_mrtLoopCounter), $WA_fieldValues);
$WA_appliedString .= "^" . WA_AB_getLoopedFieldValue($WA_loopedField, $WA_mrtLoopCounter) . "^";
$WA_appliedList[] = WA_AB_getLoopedFieldValue($WA_loopedField, $WA_mrtLoopCounter);
}
$WA_mrtLoopCounter++;
}
}
WA_AB_doManageRelationalTable($WA_valuesList, $WA_appliedString, $WA_appliedList, $WA_connection, $WA_table, $WA_masterKeyField, $WA_masterKeyType, $WA_masterKeyValue, $WA_masterKeyComp, $WA_joinedKeyField, $WA_joinedKeyType, $WA_joinedKeyComp, $WA_fieldNamesStr, $WA_columnTypesStr);
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);
}
}
?>
<?php
// WA DataAssist Pre-Select Relational Table 1
$WA_PreSelect_RelationalTable_1 = array();
$WA_connection = $boomcms;
$WA_table = "map_mc";
$WA_masterKeyField = "MANUAL_ID";
$WA_masterKeyType = "none,none,NULL";
$WA_masterKeyValue = "".$row_manual['MANUAL_ID'] ."";
$WA_masterKeyComp = "=";
$WA_joinedKeyField = "CHAP_ID";
$WA_connectionDB = $database_boomcms;
mysql_select_db($WA_connectionDB, $WA_connection);
$WhereObj = WA_AB_generateWhereClause(array($WA_masterKeyField), array($WA_masterKeyType), array($WA_masterKeyValue), array($WA_masterKeyComp));
$WA_Sql = "SELECT ".$WA_masterKeyField.", ".$WA_joinedKeyField." FROM ".$WA_table." WHERE ".$WhereObj->sqlWhereClause." ORDER BY ".$WA_joinedKeyField;
$WA_mrtJoinRS = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if (mysql_num_rows($WA_mrtJoinRS) > 0) {
while ($row_WA_mrtJoinRS = mysql_fetch_assoc($WA_mrtJoinRS)) {
$WA_PreSelect_RelationalTable_1[] = $row_WA_mrtJoinRS[$WA_joinedKeyField];
}
}
?>
<?php
// RepeatSelectionCounter_1 Initialization
$RepeatSelectionCounter_1 = 0;
$RepeatSelectionCounterBasedLooping_1 = false;
$RepeatSelectionCounter_1_Iterations = "1";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="manualschapters" name="manualschapters" method="post" action="admin_Manuals_Grouping.php">
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_chapters){
?>
<table border="0" cellspacing="0" cellpadding="0">
<?php do { ?>
<tr>
<td><?php echo $row_chapters['CHAP_TITLE']; ?></td>
<td><label>
<input type="hidden" name="WADA_RepeatID_CHAP_ID_<?php echo $RepeatSelectionCounter_1; ?>" id="WADA_RepeatID_CHAP_ID_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_chapters["CHAP_ID"]; ?>" />
<input <?php if (!(strcmp($row_chapters["CHAP_ID"],WA_AB_returnPreSelectValue($WA_PreSelect_RelationalTable_1, $row_chapters["CHAP_ID"])))) {echo "checked=\"checked\"";} ?> <?php if (!(strcmp($row_chapters['CHAP_ID'],WA_AB_returnPreSelectValue($WA_PreSelect_RelationalTable_1, $row_chapters['CHAP_ID'])))) {echo "checked=\"checked\"";} ?> type="checkbox" id="CHAP_SELECT_<?php echo $RepeatSelectionCounter_1; ?>" name="CHAP_SELECT_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_chapters['CHAP_ID']; ?>" />
</label></td>
</tr>
<?php } while ($row_chapters = mysql_fetch_assoc($chapters)); ?>
</table>
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<td>No records match your request.</td>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_chapters && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_chapters = mysql_fetch_assoc($chapters);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
<input name="SUBMIT" type="submit" value="SUBMIT" />
</form>
</body>
</html>
<?php
mysql_free_result($manual);
mysql_free_result($chapters);
?>
Any WA would be really appreciated. I can see a lot of uses for this behaviour, but am having trouble making it work. I can't use a list in this case as I intend on doing an order function on this table as well.