Need tips for Forum Database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yosuke_
Forum Commoner
Posts: 64
Joined: Tue Apr 13, 2004 12:29 pm

Need tips for Forum Database

Post by yosuke_ »

Hi!
How to make a forum? I started to make a forum, I created a tables called forums and topics. The I created everything so far that I can post a post in any forum and it I can view it, but the problem is replys. How can I add reply? do i need to create new table? Please give me some tips how to make forum database!! Thank you!
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Why not just download one of the many free forum packages (PHPBB, XMB, etc etc) and install them and see how they do it? Look at their table structure - it'll go a long way to explaining what you'll need.
User avatar
johnperkins21
Forum Contributor
Posts: 140
Joined: Mon Oct 27, 2003 4:57 pm

Post by johnperkins21 »

I thought about creating my own forum a while ago and downloaded phpBB just to see how they did it. Needless to say, I went ahead and just used phpBB on my site. They have put a lot of time and effort into creating a very good piece of forum software that works very well. If you want to do it just for the learning aspect, do as launchode suggest and look at their structure. They use 29 tables, but 3 of those are just for the polling system.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Re: Need tips for Forum Database

Post by d3ad1ysp0rk »

yosuke_ wrote:Hi!
How to make a forum? I started to make a forum, I created a tables called forums and topics. The I created everything so far that I can post a post in any forum and it I can view it, but the problem is replys. How can I add reply? do i need to create new table? Please give me some tips how to make forum database!! Thank you!
table "posts":
postid | postmsg | post_user | post_date | topicid

table "topics":
topicid | name | description | poster

Code: Select all

$result = mysql_query("SELECT * FROM posts WHERE topicid = " . $_GET['tid']);
while($row = mysql_fetch_array($result)){
$result2 = mysql_query("SELECT * FROM members WHERE username = " . $row[username]);
$row2 = mysql_fetch_array($result);
echo '<table cellspacing="0" cellpadding="0" border="0"><tr><td valign="top" width="80">';
echo "<b>" .$row[username]. "</b><br />";
echo "<b>" .$row2[title]. "</b><br />";
echo "Date: " .$row[date]. "<br />";
echo "</td><td width="*" valign="top">" .$row[postmsg]. "</td></tr></table>";
}
Quickly written, might have errors..
yosuke_
Forum Commoner
Posts: 64
Joined: Tue Apr 13, 2004 12:29 pm

Post by yosuke_ »

Thank you for the reply's!
I wan't to create forum for learning, because I wan't to learn PHP in advinced level. Does phpBB uses MySQL database? Thank you!
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

Database Server Support
phpBB uses a database abstraction layer to enable seamless support of several database servers:


MySQL 3.2x,
PostgreSQL 7.x,
Microsoft SQL Server 7/2000
Microsoft Access (via ODBC)

...with more databases available in the future.
Post Reply