SUNIL16 Posted November 5, 2008 Share Posted November 5, 2008 Hi Friends, I Created a Forum, Which is working nice but i am not getting how can i give link to the author of the post. How to retrieve his profile only, If i give link. I am Two tables One is 1]Userlist 2]Forum topic When a member send a topic. I can get his name as author, Now i want to give link to his profile in userlist table. How can i do that? Quote Link to comment https://forums.phpfreaks.com/topic/131455-querying-multiple-tables/ Share on other sites More sharing options...
Garethp Posted November 5, 2008 Share Posted November 5, 2008 Just assign the ID of the author to a variable like $AID = $Query['ID'] (Or however you call on his ID from the forum table then call on a new Query using $AID as the condition. It doesn't matter that you already queried a table, it really doesn't... Quote Link to comment https://forums.phpfreaks.com/topic/131455-querying-multiple-tables/#findComment-682730 Share on other sites More sharing options...
Adam Posted November 5, 2008 Share Posted November 5, 2008 Okay so in the topics table, how are you linking the topic to the user; by 'user id', 'username'? And where excactly are you wanting to link to the user's profile, on all the posts each user makes? Perhaps a screenshot or quick image of what you're trying to achieve might help cause I'm struggling to picture what you're trying to do... Adam Quote Link to comment https://forums.phpfreaks.com/topic/131455-querying-multiple-tables/#findComment-682797 Share on other sites More sharing options...
JasonLewis Posted November 5, 2008 Share Posted November 5, 2008 If you are storing the authors ID in the posts table, in a filed called author_id or something. Then you can do a query like this: SELECT p.*, u.username AS author_name FROM posts p LEFT JOIN users u ON (p.author_id=u.id) Looks good to me. Quote Link to comment https://forums.phpfreaks.com/topic/131455-querying-multiple-tables/#findComment-682806 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.