How to delete associated file with delete button from results page
If I've missed a tutorial somewhere, please advise. Everything I've found seems to be written before the delete record operation was changed in the "DataAssist Pages" wizard to perform the record delete on the results page rather than taking you to a separate delete page. When I insert the WebAssist > File Manipulation > Delete on the results page generated by the "DataAssist Pages" wizard, the WADeleteFile function deletes the last record in the entire results on the page, rather than the row in the recordset I clicked to delete.
How do I get the WADeleteFile function to select the record file name in association with the proper clicked row?
Here's the header code:
<?php
// WA Application Builder Delete
if (isset($_POST["Delete"]) || isset($_POST["Delete_x"])) // Trigger
{
$WA_connection = $sitecontrol;
$WA_table = "tbSlides";
$WA_redirectURL = "tbSlides_results.php?id=".((isset($_POST["WADADeleteRecordID"]))?$_POST["WADADeleteRecordID"]:"") ."";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "id";
$WA_columnTypesStr = "',none,''";
$WA_fieldValuesStr = "".((isset($_POST["WADADeleteRecordID"]))?$_POST["WADADeleteRecordID"]:"") ."";
$WA_comparisonStr = "=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_comparisions = explode("|", $WA_comparisonStr);
$WA_connectionDB = $database_sitecontrol;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$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());
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_DeleteFileResult1 = false;
if(isset($_POST["Delete"]) || isset($_POST["Delete_x"])){
$WA_DeleteFileResult1 = WA_FileAssist_DeleteFile("../cmsimages/full/", "".$row_WADAtbSlides['photo'] ."");
}
?>
And here's the code from the delete button in the row:
<input type="button" class="formButton ResultsPageButton unstyled DeleteButton" value="" onclick="document.getElementById('WADADeleteRecordID').value=<?php echo($row_WADAtbSlides['id']); ?>;document.getElementById('deleteBox').style.display = 'block';document.getElementById('deleteMessage').style.display = 'table';" />