barney0o0 Posted May 13, 2008 Share Posted May 13, 2008 Hi Chaps, something rather easy (i presume), but its something that ive never done before. When i want to delete a record a go to a new php file and use; <?php require_once('../Connections/*.php'); ?> <?php mysql_select_db($database_*, $*); $query_deleterecord = "DELETE FROM links WHERE id=". $_GET['ID']; $deleterecord = mysql_query($query_deleterecord, $*) or die("MYSQL _Error: ".mysql_error()); ?> however, how can i delete 2 records with the same id? For example i want to delete record/s from 'links' and delete record/s from 'pagelinks' WHERE links.linkid AND pagelinks.linkid = ID (sent from original page) Note, the structure for the pagelinks is CREATE TABLE `pagelinks_en` ( `pageid` int(11) NOT NULL default '0', `linkid` int(11) NOT NULL default '0', PRIMARY KEY (`pageid`,`linkid`), KEY `linkid` (`linkid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Thanks in advance b Quote Link to comment https://forums.phpfreaks.com/topic/105394-delete-two-records-from-db/ Share on other sites More sharing options...
clearstatcache Posted May 13, 2008 Share Posted May 13, 2008 try this... $delete_query = "delete links, pagelinks from links left join pagelinks on links.linkid = pagelinks.linkid where links.linkid=ID"; Quote Link to comment https://forums.phpfreaks.com/topic/105394-delete-two-records-from-db/#findComment-539769 Share on other sites More sharing options...
barney0o0 Posted May 19, 2008 Author Share Posted May 19, 2008 Cheers Mate Sorry, after i posted i realised that i needed to delete from 3 recaords rather than 2! What ive written is; $query_deleteguest = "DELETE links.linkid, pagelinks.linkid, eventlinks.linkid FROM links LEFT JOIN pagelinks on links.linkid = pagelinks.linkid LEFT JOIN eventlinks on links.linkid = eventlinks.linkid WHERE links.linkid=". $_GET['ID']; but i get an error about my syntax...any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/105394-delete-two-records-from-db/#findComment-544686 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.