
Delete from relationship table where [ID] = SubCatID

Thanks so much Jaffa,
I have tried doing this, but to be honest, I'm not grasping it within the code. The second multiple delete behavior is pasted below. I assume that I need to hand code the WHERE clause towards the bottom. But everything I try, fails.
A side note, my repeat selection uses a recordset that references only the Sub Categories table. Is there anything I need to add to the repeat selection to loop through the relational table? Or should I be using a JOIN recordset including both the SubCategory and relational table together for this repeat region/selection?
<?php
// WA DataAssist Multiple Deletes
if (isset($_POST["UpdateSubCatBtn_x"])) // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_TableID");
$WA_loopedField = array("DelSubCatchecked");
$WA_connection = $dbStore;
$WA_table = "relCat_SubCat";
$WA_redirectURL = "products_Categories.php";
$WA_keepQueryString = false;
$WA_indexField = "TableID";
$WA_columnTypesStr = "none,none,NULL";
$WA_fieldNames = explode("|", $WA_indexField);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_comparisions = array("=");
$WA_connectionDB = $database_dbStore;
$WA_multipleDeleteCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkLoopedFieldsNotBlank($WA_loopedIDField, $WA_multipleDeleteCounter)) {
if (WA_AB_getLoopedFieldValue($WA_loopedIDField[0], $WA_multipleDeleteCounter) == WA_AB_getLoopedFieldValue($WA_loopedField[0], $WA_multipleDeleteCounter)) {
$WA_fieldValuesStr = WA_AB_getLoopedFieldValue($WA_loopedIDField[0], $WA_multipleDeleteCounter);
$WA_fieldValues = array($WA_fieldValuesStr);
$deleteParamsObj = WA_AB_generateWhereClause($WA_fieldNames, $WA_columns, $WA_fieldValues, $WA_comparisions);
$WA_Sql = "DELETE FROM `" . $WA_table . "` WHERE " . $deleteParamsObj->sqlWhereClause;
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
}
$WA_multipleDeleteCounter++;
}
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);
}
}
?>
Lastly, on this delete behavior, do I use the TableID or the Parent_SubCategoryID for the index field? $WA_indexField = "TableID";
In this table, as you can see, the TableID is the unique column.
Thanks again,
TroyD