Ok, i'm working on finishing the structure for a small set of forums on my site.
I have a forums db which lists the main forums
a topics db with lists the topics with a topic id.
and a thread db which houses all the threads.
Now when you view the topic it will list all the threads and my sql statement basically says, show all threads with the topic_id of the topic they clicked on. Simple enough right?
Well, my problem is the first post or when somebody creates a new topic. I have to post the topic (subject of the new topic) to one db (topics) and then the body to the other db (threads).
Is their an easier way of doing this?
I've been fighting with this for quite a while and any help would be very appriciated.
Anthony
My forums
Moderator: General Moderators
-
pinehead18
- Forum Contributor
- Posts: 329
- Joined: Thu Jul 31, 2003 9:20 pm
Well depends on which code you want.
They are seperate tables.
The code for a new topic is as follows. But i don' wknow where to add the body at. Do i add it in the topic table or do i add it in the thread table?
feyd | removed username/password
They are seperate tables.
The code for a new topic is as follows. But i don' wknow where to add the body at. Do i add it in the topic table or do i add it in the thread table?
Code: Select all
<?php
if (isset($_POST['new_topic'])) {
$date = date("l, M, d");
$uname = "anthony";
$con = mysql_connect("localhost","*********","************") or die(mysql_error());
$db = mysql_select_db("lkcforum",$con) or die(mysql_error());
$sql = "INSERT INTO topics (topicdes,author,forum_id,date) VALUES
('$topic','$name','{$_POST['fid']}','$date')";
mysql_query($sql,$con) or die(mysql_error());
}
$output = "
<table id=table2>
<form method=post action=newthread.php>
<tr>
<td width=20%>Subject</td><td width=80%><input type=text name=topic size=80></td>
</tr>
<tr>
<td width=20%>Message</td><td width=80%><textarea cols=60 rows=20 name=body></textarea></td>
</tr>
<tr>
<td> </td><td align=center><input type=submit name='new_topic' value=Submit> <input
type=reset
name=Reset></td>
</tr>
</table>
<input type=hidden name=fid value={$_GET['f']};
";
?>feyd | removed username/password
How are your talbes laid out?
Search google for [google]normalization[/google].
here are a few good links:
http://dev.mysql.com/tech-resources/art ... ation.html
http://www.phpbuilder.com/columns/barry20000731.php3
http://www.phpbuilder.com/columns/tim20010110.php3
Search google for [google]normalization[/google].
here are a few good links:
http://dev.mysql.com/tech-resources/art ... ation.html
http://www.phpbuilder.com/columns/barry20000731.php3
http://www.phpbuilder.com/columns/tim20010110.php3