Hey all,
I'm currently running an installation of phpBB, and I need to grab the first post of each topic in a specific forum so that I can echo the data later on in the script. I have all my functions and includes setup so that I can use phpBB's BBcode and such, but I used a MYSQL query I had found on the net when coding the script. The query used to grab all the data is:
$result = mysql_query("SELECT DISTINCT t.topic_id, t.topic_title, t.topic_replies, u.user_id, u.username, s.post_text
FROM phpbb_posts p, phpbb_topics t, phpbb_users u, phpbb_posts_text s
WHERE p.topic_id = t.topic_id AND t.topic_poster = u.user_id AND t.topic_first_post_id = s.post_id AND t.forum_id = 1
ORDER BY t.topic_time DESC LIMIT 5");
The code works well how it is, but I'd like to also pull p.post_time for each post from the database. Unfortunately, I can't seem to do so without then receiving duplicate results (the ones filtered out using DISTINCT) I'm terrible with my SQL queries, and so I can't figure out how to best go about accomplishing this. Could someone show me how to re-write this query so that it also grabs p.post_time from the database?
Thanks,
Daniel