Results 1 to 2 of 2

Thread: php mysql counting replies on messages

  1. #1
    Join Date
    Aug 2005
    Posts
    1

    Question php mysql counting replies on messages

    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

  2. #2
    Join Date
    Mar 2004
    Location
    China
    Posts
    3,315
    PHP Code:
    $result mysql_query('SELECT * FROM tablename WHERE ReplyId = $messageID;')
    $numb_replies mysql_num_rows($result);
    echo 
    $numb_replies

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •