HighDots Forums  

Deleting from 2 MSQL tables with one button

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Deleting from 2 MSQL tables with one button in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
smiffy47
 
Posts: n/a

Default Deleting from 2 MSQL tables with one button - 07-31-2008 , 03:31 AM






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 DW 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


Reply With Quote
  #2  
Old   
smiffy47
 
Posts: n/a

Default Re: Deleting from 2 MSQL tables with one button - 08-03-2008 , 05:49 PM






Problem has now ben sorted.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.