Hello every one
I have a forum written in php language. What I want is to display all the comments made by one user on a certain topic.
The database had two tables "forum" and "comment".
Forum table is structured as follows:
id cat_id title date_time userid name post allow usesig iconid uploadfile reader c_comment sticky close lastuserid timestamp edit_by ip_address rating_total ratings
Comment table is structured as follows:
id modType thread_id userid name title comment news_c_allow cat_id usesig uploadfile timestamp allow
All comments are linked back to the original thread by the "thread_id". And of course the cell "userid" refer to the id of the user in the users table in the Database.
I want to retrieve all the comments by one user, however I want to display the title of the thread and not the title of the comment (Even if it occurs more than one time).
I use this code to retrieve the information:
$result = $apt->query("SELECT DISTINCT forum.*, comment.* FROM forum JOIN comment ON forum.userid=comment.userid WHERE comment.userid = $userid ORDER BY forum.timestamp DESC LIMIT $start,$perpagelist");