Jump to content

News System


jrws

Recommended Posts

Hi guys I was wondering how I would implement the ability to see what posts a user has made. I would be thinking a join, but don't know which join to use, as they are confusing to me.

Basically I want to make it so that when you are on the users page, it will say stuff like:

Username: blah

Email: blah@blah.com

Posts: number of posts, and or links to the posts

 

Mind you I just want to test this thing out, because as soon as I understand how to do it I can perform other functions. So if anyone can explain in an easy way or help me that would be great. I have already looked at many tutorials about left joins and right joins and joins in general. However like I have stated, I don't know how to use them properly.

Link to comment
Share on other sites

I really don't think you quite understand what my delema is. I know what the joins are, but I don't know what the format for this situation would be for what I want, and I can't seem to find any information on it. Thanks again, I guess I will just have to look harder.

Link to comment
Share on other sites

jrws, I hear what you're saying.

 

The things got me confused as well to begin with. I knew what they were and how they can help but could never get them working without someone else fixing the queries for me at which point I'd be lost as to what the changes did and why.

 

A normal query queries one table.

 

A normal join (can't remember the term for it) is used when two tables always contain data that can be matched. For example, an "albums" table and a "track listings" table - albums always have tracks even if its only one.

 

A left join is handy for using when the second table doesn't always contain data to match with the first. For example, a "track listing" table and a "remix name" table as not all tracks on an album would be remixed.

Link to comment
Share on other sites

Alright thanks for that, that helps a little, could you perhaps help me then with figuring out what records it would be for a user table and post id

So for example

id of user links to the post u_id

But I want it so that it counts how many articles the user would of posted, so in that case how many times the same u_id appears. How would I do this? Would this be a join or a normal where clause?

Link to comment
Share on other sites

Sorry didn't mean to lose you. Basically I don't know if I want a where clause like 'SELECT * FROM $table WHERE something = '$something';

Or if I needed a join

 

What I want to do is find out how many posts as user has made, the way I have made the tables they only would share two things, the author as the username of the poster and the user id as the id of the user (am I making sense?)

So then I would like to count how many times the user id is repeated in the news table, perhaps author would be better. After that I want PHP to spit out the results. I am going to see if I can find some open source software which may have the answer.

 

Thanks again,

Hopefully I made a bit more sense this time.

Link to comment
Share on other sites

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.