1 down vote favorite
You can't vote for your own post.
(click on this box to dismiss)

I have a very big problem with my website. I have a form, more like a text box used in submitting comments, that not the problem. The problem is displaying the comments. I want to display comments based on the friends a user added like the way facebook, twitter does.

I have 3 tables:photo_tb, comment_tb, friendship_tb.

The friendship_tb contains columns name, friend. name stores your email and friend stores the email of the person you add....

I need the photo_tb to get the picture of the person making the comment and I use a mysql join successfully.

In my comment_tb...i get the email of the person making the comment in my commentname column and comment made by the person...

I want to to show comment by friendship like if Mr A adds Mr B and Mr c..when Mr A logs on he should only get comments by both Mr B and Mr c and his comments doe not comments from Mr G or H.

This is what i have so far... IT shows comment of a users not added..eg mr a doesnt add mr b and is getting comments made mr b.Please help me

SELECT
     comment_tb.comment_id
   , comment_tb.comname
   , comment_tb.comment
   , comment_tb.time
   , photo_tb.name
   , photo_tb.photo
   , friendship.name
   , friendship.member
FROM comment_tb, photo_tb, friendship
WHERE
        comment_tb.comname=photo_tb.name
    and friendship.name = colname
    and and friendship.member = comment_tb.comname.

In your query, I have a hard time to figure out how a "log in" user is being distinguish from the query. Also, there are multiple mistake in your sample query above and I am not sure what you mean. What is "colname"? Why there are 2 "and" in the query? Why the friendship table contains "member" but your explanation is talking about "friend" column instead? In other words, the table columns do not describe its relationship with other tables, and that would be more difficult for others to understand for.

:photo_tb:     :comment_tb:      :friendship:
  name <----     comment_id        name <------ user identification
  photo     '--> comname <-------> member
            ^    comment     ^
            |    time        |
            |                |_ comment owner
          person
        who makes
          comment

If Mr.A has logged in, how would you know that the friendship.name is supposed to be the person who is calling from your sample query?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.