graham23s Posted July 30, 2007 Share Posted July 30, 2007 Hi Guys, just after some advice on this, when a user visits another members profile whats the best way to store it in mysql? currently when a user visits a page i increment the views by 1, i take it i grab the logged in users id and would store it is that right? cheers Graham Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted July 30, 2007 Share Posted July 30, 2007 i take it i grab the logged in users id and would store it is that right That is correct. You would use a many-to-many relationship. Quote Link to comment Share on other sites More sharing options...
graham23s Posted July 30, 2007 Author Share Posted July 30, 2007 Hi Mate, Thanks for the input mate, i already have a table that stores users username,password,age and all other details, should i make a whole new table for this like: profiles_viewed id user_id recipient_id kinda thing? cheers mate Graham Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted July 30, 2007 Share Posted July 30, 2007 should i make a whole new table for this like: profiles_viewed id user_id recipient_id kinda thing? yep Quote Link to comment Share on other sites More sharing options...
graham23s Posted July 30, 2007 Author Share Posted July 30, 2007 Then while loop through the id's getting the users names and displaying them eh? excellent i now have a plan of action lol cheers mate Graham Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted July 30, 2007 Share Posted July 30, 2007 Use a join, not a while loop...something like this... SELECT p2.user FROM profiles_viewed pv LEFT JOIN profiles p1 ON pv.userid = p1.userid LEFT JOIN profiles p2 ON pv.recipientid = p2.userid WHERE p1.user = 'some user name' 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.