steviez Posted February 9, 2007 Share Posted February 9, 2007 Hi, I have some sql code that executes when a user clicks a button: $sql = "DELETE FROM user WHERE id = '$UsErId'"; The problem is that i need two or three more querys to be executed with the same button, how can this be done? Any help would be great! Steve Link to comment https://forums.phpfreaks.com/topic/37694-solved-query-help/ Share on other sites More sharing options...
artacus Posted February 9, 2007 Share Posted February 9, 2007 This has to be done from a php page so just run the query, then the next then the next. Or if they are all related, you could join them and do the delete. Link to comment https://forums.phpfreaks.com/topic/37694-solved-query-help/#findComment-180274 Share on other sites More sharing options...
steviez Posted February 9, 2007 Author Share Posted February 9, 2007 They are all to delete but from different bits (user, audio etc) How do i do this? Sorry for my lack of knowlage but im new to php Link to comment https://forums.phpfreaks.com/topic/37694-solved-query-help/#findComment-180280 Share on other sites More sharing options...
artacus Posted February 9, 2007 Share Posted February 9, 2007 Well do you know how to join tables? If so, you can do it all in 1 query. But just change your code: $sql = "DELETE FROM user WHERE id = '$UsErId'"; $result = mysql_query($sql) or die(mysql_error()); $sql = "DELETE FROM audio WHERE userid = '$UsErId'"; $result = mysql_query($sql) or die(mysql_error()); $sql = "DELETE FROM photos WHERE userid = '$UsErId'"; $result = mysql_query($sql) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/37694-solved-query-help/#findComment-180284 Share on other sites More sharing options...
Democreous Posted February 9, 2007 Share Posted February 9, 2007 I'm new too, but I'm gonna give this a shot your query $sql = "DELETE FROM user WHERE id = '$UsErId'"; deletes a single row right? To delete multiple rows try $sql = "DELETE FROM user,audio, etc WHERE id = '$UsErId'"; or if that doesn't work $sql = "DELETE FROM user && audio && etc WHERE id = '$UsErId'"; that's my best shot Link to comment https://forums.phpfreaks.com/topic/37694-solved-query-help/#findComment-180286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.