zelig Posted February 25, 2012 Share Posted February 25, 2012 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 More sharing options...
scootstah Posted February 25, 2012 Share Posted February 25, 2012 Try $result1 = mysql_query("delete FROM `users` WHERE militia=$id") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/257757-delete-info-from-two-tables/#findComment-1321092 Share on other sites More sharing options...
zelig Posted February 25, 2012 Author Share Posted February 25, 2012 It still deleted from the `orgs` table, but not the `users` table. No error was reported. Link to comment https://forums.phpfreaks.com/topic/257757-delete-info-from-two-tables/#findComment-1321093 Share on other sites More sharing options...
zelig Posted February 25, 2012 Author Share Posted February 25, 2012 Anyone have any other ideas? Thanks! Link to comment https://forums.phpfreaks.com/topic/257757-delete-info-from-two-tables/#findComment-1321141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.