xwishmasterx Posted April 26, 2011 Share Posted April 26, 2011 I am trying to do a query for members in my database but I need to go through different tables to get those members I want. Let me try too describe: I want the members who has same team_id as current member (from same table) I want only the members who are online (from another table where time stamps are, which has members id, but not team id) I simply cannot figure out how to only get members with same team id as the current member, from the table with time stamps. Anyone can point me in the right direction, or is the above just not making sense at all? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted April 26, 2011 Share Posted April 26, 2011 could you post the structure of your 3 tables? easiest way: show create table my_table Quote Link to comment Share on other sites More sharing options...
fugix Posted April 26, 2011 Share Posted April 26, 2011 you could possibly create a few while loops inside of each other to get the correct values that you would like...and use those values for your next while loop until you get the correct query Quote Link to comment Share on other sites More sharing options...
xwishmasterx Posted April 26, 2011 Author Share Posted April 26, 2011 I think I found a way to add the team_id to the tracking table, but cannot seem to get it just right. Found this piece of code: //Add to Tracking $remote_ip = $_SERVER[REMOTE_ADDR]; $UPD_SQL = "INSERT INTO vtp_tracking(credit_members_id,debit_members_id,url_id,action_date,remote_ip,teamid) VALUES('$members_id','$url_members_id','$url_id', NOW() , '$remote_ip' );"; So I added a column in above table named teamid (added this to above code also). how can I add the result of this query to the above code VALUES?: $sql= "SELECT team_id FROM vtp_members WHERE id=$members_id"; $result = mysql_fetch_array( $sql ); Quote Link to comment Share on other sites More sharing options...
fugix Posted April 26, 2011 Share Posted April 26, 2011 you could possibly use a join in your mysql query Quote Link to comment 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.