I made a forum. All works well but with one exception. If a reply has not been made to a topic, the topic does not appear on the list of topics.
Here is the query I am using:
Code:
SELECT t.*, r.*, DATE_FORMAT(t.topic_last_reply, '%c/%e/%Y %l:%i %p') AS convdate FROM topics t JOIN replies r ON (t.topic_id = r.reply_topic) WHERE t.topic_forum = ".$_GET['forum_id']." GROUP BY t.topic_subject ORDER BY t.topic_last_reply DESC
When a reply is made, it increments the value in topic_num_replies +1. So what I did is add a HAVING clause:
Code:
SELECT t.*, r.*, DATE_FORMAT(t.topic_last_reply, '%c/%e/%Y %l:%i %p') AS convdate FROM topics t JOIN replies r ON (t.topic_id = r.reply_topic) WHERE t.topic_forum = ".$_GET['forum_id']." GROUP BY t.topic_subject HAVING t.topic_num_replies >= 0 ORDER BY t.topic_last_reply DESC
I get the same result. As soon as I make a reply to the topic it appears on the list.
Thanks for your advice!