Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/131455-querying-multiple-tables/
Share on other sites

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...

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

 

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. :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.