Jump to content

[SOLVED] How would you do forum topic replies?


DrRobot

Recommended Posts

ok, so i got a user system awhile ago on the web and i've been editing it extremely, now i am making a forum, and i got it so it will display the topics, and the threads created, but i can't get it to update the replies in each topic and thread.

 

how would i do this?

I don't see how this has anything to do with OOP.

 

You need to store all the replies in a separate table, set the table up like this:

 

TABLE "replies"
---------------
replyID (Primary Key)
topicID (The topic they are posting the reply on)
poster (Who is posting the topic)
body (the actual reply)

 

Then you can just make a simple query grabbing the replies for that topic.

 

SELECT reply, poster FROM replies WHERE topicID='$topicID'

 

Does that make enough sense?

 

 

 

no, i have my functions in classes.

 

and i want to know how you would go about updating the current amount of replies in a thread, such as this one, like when you are looking at the OOP help thread it says 2 replies next to my thread (now three)

 

i have a function that is supposed to update it, but it doesn't...

 

code:

function updateTopicTime($id){
      $day = date("Y-m-d");
      $time = date("g:i:s A");
      $q = "UPDATE ".TBL_TOPICS." SET time = '$time', date = '$day', threads += '1' WHERE fid = '$id'";
      mysql_query($q);
   }
   function addNewForumThread($fid, $topic, $uname, $text){
      $day = date("Y-m-d");
      $time = date("g:i:s A");
      $this->updateTopicTime($fid);
      $q = "INSERT INTO ".TBL_THREADS." VALUES ('$fid', '', '$topic', '$uname', '$text', '$day', '$time', '')";
      mysql_query($q, $this->connection);
   }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.