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
https://forums.phpfreaks.com/topic/257757-delete-info-from-two-tables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.