182x Posted July 20, 2007 Share Posted July 20, 2007 hey guys, I have a page which displays a tables of users from a database and I on this page the user can select someone to remove from the database in order to do this they select the username from a listbox which only contains the userIds. When this userId is sent for processing I would also like to be able to send the related username without the user having to select it. How can I do this? Thank you Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/ Share on other sites More sharing options...
182x Posted July 20, 2007 Author Share Posted July 20, 2007 That may not have been clear I mean how do I send the extra piece of information, I have already got the rest setup. Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303112 Share on other sites More sharing options...
cooldude832 Posted July 20, 2007 Share Posted July 20, 2007 if you are removing why would you need more than the ID or are you trying to echo $username". Has been Removed."; if so you should query for the data before you remove it then remove it Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303113 Share on other sites More sharing options...
182x Posted July 20, 2007 Author Share Posted July 20, 2007 I also have to delete data from another table when data is deleted from the first one and the username is what links the tables Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303116 Share on other sites More sharing options...
cooldude832 Posted July 20, 2007 Share Posted July 20, 2007 thats a poor structure, but anyway query off the ID on table1 and use the query result to kill table 2 also Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303117 Share on other sites More sharing options...
182x Posted July 20, 2007 Author Share Posted July 20, 2007 Thanks, how do you query off the first query result? Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303119 Share on other sites More sharing options...
trq Posted July 20, 2007 Share Posted July 20, 2007 mysql_query(). Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303121 Share on other sites More sharing options...
cooldude832 Posted July 20, 2007 Share Posted July 20, 2007 <?php $q = "select Username from `table` where UserID = '$_POST['userid']; $result = mysql_query($q) or die(mysql_error()); if(mysql_num_rows($result)){ $row = mysql_fetch_array($result); $q2 = "Delete from `table2` WHERE Username = '$row['username']"; $result2 = mysql_query($q2) or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303122 Share on other sites More sharing options...
182x Posted July 20, 2007 Author Share Posted July 20, 2007 Thats awesome, thanks for your help. Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303124 Share on other sites More sharing options...
cooldude832 Posted July 20, 2007 Share Posted July 20, 2007 read up on database normalization because the linking key between tables is generally suppose to be an integer value that is the primary key of another table. Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303128 Share on other sites More sharing options...
182x Posted July 20, 2007 Author Share Posted July 20, 2007 I will do, Just tried the code. It didn't work It first gave a syntax error because of the extra " ' " so I removed it and added braces. But then I get the the following error where jess is an actual username. Anyideas why this is happening? Unknown column 'jess' in 'where clause' Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303145 Share on other sites More sharing options...
unidox Posted July 20, 2007 Share Posted July 20, 2007 I am a bit confised, what are you trying to do? Link to comment https://forums.phpfreaks.com/topic/60907-logic-error/#findComment-303152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.