Jump to content

Create a forum.


Recommended Posts

Most poeople wouldn't try to code one from scratch, just download a whole package like phpBB3


Run it to install, then use the admin menus to set up boards, permissions and any other edits that you want. I changed to background-image on mine, I had to search a lot of files to find the default one, but coding edits should be as few as possible or you will risk affecting the performance, just use the admin menus from the admin control panel.


There are different skins or themes available. These seem to be coded by other people but I assume that phpBB approve them.



Some people use Wordpress http://wordpress.org/ which is blog software but you can make a forum from it.

Edited by Wickham
  • Upvote 1
Link to comment
Share on other sites

Btw, there is just two things I need help with. The first is how to design good forum tables. (I suck at designing with CSS)

The second thing is to add answers. I have to tables is my DB, one for forum questions and one for forum answers. I just need help to display the right answers inside the right forum thread, and how to display the answers.

Link to comment
Share on other sites

My suggestion is to download whatever forum you like to use as a go by for learning how they put it together and then you can start your's via from scratch. Otherwise, you will need to learn just about anything and everything php and apply what you learn to your forum project.


Warning: lots of long hours...lots of stress...lots of headaches...lots of sleepless nights. And once you have launch your final project then you will have lots of headaches again due to security issuess with all kinds of hackers along with spammers, etc.


Don't get me wrong, I am not trying to discourage you but only stating the fact of what's involved here. :)


Yep, if you are single and don't have a life then go for it. Otherwise I would go with what Wickham suggested.

Link to comment
Share on other sites

I figured it out, but I have one problem.


When I am supposed to add a answer the first answer gets added, but thats it.


The id of the answer is not auto_increment, but it makes the id to what the id of the thread is.

But I seem to be only able to add one id with a number, not several ids with same numers. How can I do that?

Link to comment
Share on other sites

Only missing one thing. When someone posts a new answer I would like the thread to go to the top, how can I do that?

Two hours eh and now this question? You are just beginning to scratch the surface here. You want the post to be at the top but what about archive? search post? results order? users? login? account info? security? navigation?


What you seem to have achieved is a simple post with a comment section. That's not really a forum. So maybe you didn't mean to use the word 'forum' for what you are trying to achieve.



Link to comment
Share on other sites

That is actually no use for me.


I would like to know how to put threads to the top when someone comments in the thread.


I have actually thought about making my own forum, for the practice, for a while. I'm actually waiting for a friend of mine to pick up PHP, though. That way we can collaborate ideas and theories on how to do things a lot better.


Getting to your question:


Assuming this style of database layout:


  • threads table - This table would contain the thread name / Poster ID / whatever else is related to that specific thread specifically.
  • thread_replies table- This table would contain the post information (The various replies to the thread, containing the thread ID of the thread they belong to.)


Example fields for the table `threads` (Because that's the one you'll need to focus on for this):



  • thread_id (Auto-Incremented Thread ID)
  • op_id (The Original Poster's (OP) user/account ID)
  • thread_title
  • start_date (MySQL DATETIME of the date the thread was created.)


Then, I would add a field `last_post_time` as either MySQL DATETIME or an INT containing the time() ( http://us3.php.net/manual/en/function.time.php ) timestamp of the latest post (Update it every time some one replies). Then in the section that lists the threads (not the replies, just the threads like you mentioned), do an:


ORDER BY `last_post_time` DESC


At the end, making the whole query something like (Just guessing, since I don't have your code I don't know the exact query or database structure you use):


SELECT * FROM `threads` ORDER BY `last_post_time` DESC


And it will return a list of threads ordering the latest post times at the top.



Hope that helps :)


Edit: Reading this post I'm not really sure if you have made a forum or a comment section on a blog post like thing (And are in fact wanting the comments to go to the top).


Either way, I will leave this here. It's easily adaptable to whatever you might need it for. The main point is the DATETIME / Timestamp storage and then ordering by it descending.

Edited by Coreinsanity
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...