Hey,
Im trying to put together a forum, and so far so good... exept when trying to get the last poster...
I have 2 tables, 1 for the Forums, and the 2nd is for posts AND replys:
id_msg
idtop_msg // Forum ID
idmsg_msg // Is NULL if it the FIRST thread, all replys get the value of id_msg
id_init_msg // Gets the value of id_msg (both first post and replys)
idusr_msg // user ID
date_msg
subject_msg
content_msg
subscribe_msg // receive email if its replied to
This is the sql ive tried to get the last post and total posts which does work:
SELECT COUNT(message_msg.id_msg) as total_posts, topic_top.id_top, topic_top.title_top, topic_top.description_top, topic_top.locked_top, DATE_FORMAT(MAX(message_msg.date_msg), '%D %b %Y') as last_post_date, MAX(message_msg.idusr_msg) as last_poster
FROM topic_top LEFT JOIN message_msg ON topic_top.id_top = message_msg.idtop_msg LEFT JOIN members ON message_msg.idusr_msg = members.m_id
WHERE topic_top.parent_top=123456789
GROUP BY topic_top.id_top
ORDER BY topic_top.id_top
In testing it gets the right date, and user ID... but how do i get the username from the members table? I tried taking the last_poster from the SQL above and made another recordset to get the username if message_msg.last_poster = members.m_id but nothing.
Any suggestions?
Thanks in advance,
Danny Lewin