Jump to content

delete info from two tables


zelig

Recommended Posts

I'm wanting to delete information that is located in two different tables.

 

It will delete from one table (`orgs`) but not from the other (`users`). So, the issue is somewhere with $result1.

 

Any help would be appreciated!

 

Thanks in advance!

 


function delmilitia() {

if (isset($_POST['delete'])) {
	$id = $_POST['id'];
	$peep = ucwords(strtolower($action3[1]));
	$dbh=dbconnect() or die ('GetUser error: ' . mysql_error()."<br>");
	mysql_select_db("katarra_live");
	$result = mysql_query("delete FROM `orgs` WHERE id=$id");
	$result1 = mysql_query("delete FROM `users` WHERE militia=$id");
}
if (isset($_POST['clear'])) {
	$dbh=dbconnect() or die ('GetUser error: ' . mysql_error()."<br>");
	mysql_select_db("katarra_live");
	$result = mysql_query("delete FROM `orgs` WHERE id=$id");
	$result1 = mysql_query("delete FROM `users` WHERE militia=$id");
}
$page = "<b><u>Delete Militia</b></u><br /><br />Click the Delete button next to the appropriate entry to remove that entry from the database.";
$delquery = doquery("SELECT * FROM `orgs` ORDER BY name", "orgs");
while ($delrow = mysql_fetch_array($delquery)) {
	if ($bg == 1) { $page .= "<div style=\"width:98%; background-color:#eeeeee; font-family: tahoma; font-size: 8pt; line-height: 1.4em; color: #0A3549;\"><form action=\"admin_panel.php?do=delmilitia\" method=\"post\"><p><input type=\"submit\" value=\"Delete\" name=\"delete\"> <input type=\"hidden\" name=\"id\" value=\"".$delrow["id"]."\"><b>".$delrow["name"]."</b></p></form></div>\n"; $bg = 2; }
	else { $page .= "<div style=\"width:98%; background-color:#ffffff; font-family: tahoma; font-size: 8pt; line-height: 1.4em; color: #0A3549;\"><form action=\"admin_panel.php?do=delmilitia\" method=\"post\"><p><input type=\"submit\" value=\"Delete\" name=\"delete\"> <input type=\"hidden\" name=\"id\" value=\"".$delrow["id"]."\"><b>".$delrow["name"]."</b></p></form></div>\n"; $bg = 1; }  
}
admindisplay($page, "Delete Militia");

}   

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.