PDA

View Full Version : php mysql counting replies on messages



ginababy
09 Aug 2005, 12:55 PM
Hi
I am creating a forum on my website - and I am trying to list how many replies I have had on each forum message. How do I do this in SQL and php?
This is my message database

MeldingID(Message ID), BrukerID(UserID), SvarMeldingID(ReplyID*), Tittel(Title), Melding(Message), Date, KategoriID(ForumId)

*ReplyId is has the value NULL if it is the start of a thread and value= messageID if it an reply on a message.

WHen listing all the message titles in the forum preview page I would like to
show it like this

Tittle(being a link to the message with all the replies spelled out), UserId, Date , and amount of replies on this message (Counting the amount of SvarID that has the same Message Id as the tittle) - if you understand.
PLEASE HELP ME
I have been working on this now for weeks - and I am getting a bit frustrated :)

Rincewind
10 Aug 2005, 10:35 AM
$result = mysql_query('SELECT * FROM tablename WHERE ReplyId = $messageID;')
$numb_replies = mysql_num_rows($result);
echo $numb_replies;