PRodgers4284 Posted March 16, 2008 Share Posted March 16, 2008 Im want to delete records from two tables, the tables are called "employers" and "job". I am want to delete records based on the username in each table. Im using the following query but im not sure if the syntax is correct for deleting from two tables: mysql_query("DELETE FROM employers && job WHERE username='$username'"); Can anyone help? Link to comment https://forums.phpfreaks.com/topic/96393-deleting-records-from-two-tables/ Share on other sites More sharing options...
Barand Posted March 16, 2008 Share Posted March 16, 2008 DELETE FROM employers e , job j WHERE e.username = j.username AND e.username = '$username' Link to comment https://forums.phpfreaks.com/topic/96393-deleting-records-from-two-tables/#findComment-493341 Share on other sites More sharing options...
PRodgers4284 Posted March 16, 2008 Author Share Posted March 16, 2008 Hey thanks for the reply, i tried the query you suggested, but it doesnt same to be deleting the records, below is the php code I have now: <?php $username = $_GET['username']; if (isset($_POST['submit'])) { mysql_query("DELETE FROM employers e , job j WHERE e.username = j.username AND e.username = '$username'"); ?> <br /> <a href="Indexadmin.php">Back to main page</a> <br /> <br /> <br /> The Employer account for <b><?php echo $username; ?></b> has been deleted from the system <?php } else { $account = mysql_fetch_array(mysql_query("SELECT * FROM employers WHERE username='$username'")); ?> Link to comment https://forums.phpfreaks.com/topic/96393-deleting-records-from-two-tables/#findComment-493346 Share on other sites More sharing options...
Barand Posted March 16, 2008 Share Posted March 16, 2008 One question comes to mind If you are POSTing data, why is username coming from GET Link to comment https://forums.phpfreaks.com/topic/96393-deleting-records-from-two-tables/#findComment-493583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.