How did they do that

Hi, im creating a forum for my site and need help…
If I choose a category (Welcome) I’m taken to a list of posts in that category, http://coronadoshores.ca/community/category.php?id=1&topic=Welcome
You then click on the replies link to see the 2 replies, http://coronadoshores.ca/community/post.php?id=3
I dont like how the page seems to loose the stuff for the original post.
The effect im looking for is this, http://www.phpjabbers.com/preview/stiva-forum/
(Where the original stuff is retained after the reply link is checked, I just dont know how they did that).
I really like that effect and I want to learn how I can do it.

Thanks

The same way they did it in the first place?

qid=3 identifies the question; so you can query the information for the original post in the same way.

the query that I use, http://coronadoshores.ca/community/post.php?id=3
is

SELECT mess.subject, mess.message_txt, mess.mess_id, mess.parent_id, mess.created, users.name
FROM messages AS mess
INNER JOIN `users` 
ON users.id =  mess.user_id
WHERE mess.parent_id = 3
GROUP BY mess.created

The query I use on, http://coronadoshores.ca/community/category.php?id=1&topic=Welcome
is

SELECT mess.subject, mess.message_txt, mess.mess_id, mess.parent_id, mess.created, users.name,
COUNT(rply.parent_id) AS replies
FROM messages AS mess
INNER JOIN `users` 
ON users.id =  mess.user_id
LEFT OUTER JOIN messages AS rply
ON rply.parent_id = mess.mess_id
WHERE mess.topic_id = 1
AND mess.parent_id IS NULL
GROUP BY mess.mess_id

(left joins are confusing to me), because I dont want to have 2 queries I think ill need 1.


The screenshot is the messages table of which the message im looking for has a parent_id of NULL and a topic_id of 1,
Here the query i think i need to add the original post to with a left join of some kind

Left joins are simply saying “I want everything from table A, regardless of if there is matching data in table B. But if there is matching data in table B, i want that too.”

(Right joins are the same, but invert A and B)

Inner joins are: Show me things where there is matching data in A and B.

The way generally forums work is that they seperate the logic of ‘parent’ from ‘topic’. All posts simply belong to a singular topic (thread, whatever), and so all messages in a given thread can be referenced as SELECT stuff FROM posts WHERE thread = somethreadid ORDER BY DATE (since noone can post into a thread before the original post in the thread because that’s how linear time works in our dimension of understanding.)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.