As I have been able to add data to two mysql tables with a single button I imagine I should be able to delete both entries in a similar manner, but I can't seem to make it happen. The code is largely written by DreamW and I have only the dimmest inkling of the meaning of the php, so please be patient in any explanation as to where I am going wrong!
At present the entry to the table chk_sixmonth is being deleted, but at table cel_contents incorrect records are being deleted.
The relevant code is, I think;
if ((isset($_POST['ck_pk'])) && ($_POST['ck_pk'] != "") && (isset($_POST['gone']))) {
$deleteSQL = sprintf("DELETE FROM chk_sixmonth WHERE ck_pk=%s",
GetSQLValueString($_POST['ck_pk'], "int"));
mysql_select_db($database_tormented3, $tormented3);
$Result1 = mysql_query($deleteSQL, $tormented3) or die(mysql_error());
$deleteGoTo = "chk_insert.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
if ((isset($_POST['cel_pk'])) && ($_POST['cel_pk'] != "") && (isset($_POST['gone']))) {
$deleteSQL = sprintf("DELETE FROM cel_contents WHERE cel_pk=%s",
GetSQLValueString($_POST['cel_pk'], "int"));
mysql_select_db($database_tormented3, $tormented3);
$Result1 = mysql_query($deleteSQL, $tormented3) or die(mysql_error());
$deleteGoTo = "chk_insert.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_rstSix = "1";
if (isset($_GET['scrap'])) {
$colname_rstSix = (get_magic_quotes_gpc()) ? $_GET['scrap'] : addslashes($_GET['scrap']);
}
mysql_select_db($database_tormented3, $tormented3);
$query_rstSix = sprintf("SELECT * FROM chk_sixmonth WHERE ck_pk = %s", $colname_rstSix);
$rstSix = mysql_query($query_rstSix, $tormented3) or die(mysql_error());
$row_rstSix = mysql_fetch_assoc($rstSix);
$totalRows_rstSix = mysql_num_rows($rstSix);
$colname_rstCont = "1";
if (isset($_GET['scrap2'])) {
$colname_rstCont = (get_magic_quotes_gpc()) ? $_GET['scrap2'] : addslashes($_GET['scrap2']);
}
mysql_select_db($database_tormented3, $tormented3);
$query_rstCont = sprintf("SELECT * FROM cel_contents WHERE cel_pk = %s", $colname_rstCont);
$rstCont = mysql_query($query_rstCont, $tormented3) or die(mysql_error());
$row_rstCont = mysql_fetch_assoc($rstCont);
$totalRows_rstCont = mysql_num_rows($rstCont);
?>
<!DOCTYPE etc ......
<form action="" method="post" name="scrap" id="scrap">
<input name="gone" type="checkbox" id="gone" value="gone" />
<input type="submit" name="Submit" value="Delete" />
<input name="ck_pk" type="hidden" id="ck_pk" value="<?php echo $row_rstSix['ck_pk']; ?>" />
<input name="cel_pk" type="hidden" id="cel_pk" value="<?php echo $row_rstCont['cel_pk']; ?>" />
</form>
Thanks for any help
At present the entry to the table chk_sixmonth is being deleted, but at table cel_contents incorrect records are being deleted.
The relevant code is, I think;
if ((isset($_POST['ck_pk'])) && ($_POST['ck_pk'] != "") && (isset($_POST['gone']))) {
$deleteSQL = sprintf("DELETE FROM chk_sixmonth WHERE ck_pk=%s",
GetSQLValueString($_POST['ck_pk'], "int"));
mysql_select_db($database_tormented3, $tormented3);
$Result1 = mysql_query($deleteSQL, $tormented3) or die(mysql_error());
$deleteGoTo = "chk_insert.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
if ((isset($_POST['cel_pk'])) && ($_POST['cel_pk'] != "") && (isset($_POST['gone']))) {
$deleteSQL = sprintf("DELETE FROM cel_contents WHERE cel_pk=%s",
GetSQLValueString($_POST['cel_pk'], "int"));
mysql_select_db($database_tormented3, $tormented3);
$Result1 = mysql_query($deleteSQL, $tormented3) or die(mysql_error());
$deleteGoTo = "chk_insert.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_rstSix = "1";
if (isset($_GET['scrap'])) {
$colname_rstSix = (get_magic_quotes_gpc()) ? $_GET['scrap'] : addslashes($_GET['scrap']);
}
mysql_select_db($database_tormented3, $tormented3);
$query_rstSix = sprintf("SELECT * FROM chk_sixmonth WHERE ck_pk = %s", $colname_rstSix);
$rstSix = mysql_query($query_rstSix, $tormented3) or die(mysql_error());
$row_rstSix = mysql_fetch_assoc($rstSix);
$totalRows_rstSix = mysql_num_rows($rstSix);
$colname_rstCont = "1";
if (isset($_GET['scrap2'])) {
$colname_rstCont = (get_magic_quotes_gpc()) ? $_GET['scrap2'] : addslashes($_GET['scrap2']);
}
mysql_select_db($database_tormented3, $tormented3);
$query_rstCont = sprintf("SELECT * FROM cel_contents WHERE cel_pk = %s", $colname_rstCont);
$rstCont = mysql_query($query_rstCont, $tormented3) or die(mysql_error());
$row_rstCont = mysql_fetch_assoc($rstCont);
$totalRows_rstCont = mysql_num_rows($rstCont);
?>
<!DOCTYPE etc ......
<form action="" method="post" name="scrap" id="scrap">
<input name="gone" type="checkbox" id="gone" value="gone" />
<input type="submit" name="Submit" value="Delete" />
<input name="ck_pk" type="hidden" id="ck_pk" value="<?php echo $row_rstSix['ck_pk']; ?>" />
<input name="cel_pk" type="hidden" id="cel_pk" value="<?php echo $row_rstCont['cel_pk']; ?>" />
</form>
Thanks for any help