Lid |
|
Hey allemaal, ik ben bezig met m'n eigen forum script waarvan ik het al aardig op weg ben maar ik zit nu echt met een probleem.
Het probleem is dat je bijv nadat je een topic hebt geplaats (nieuwe topic dus) dan kan je eigenlijk ook daarop reageren maar bij is het als je 'Reply' plaats dan pakt ie het 'id' van de topic en dus dan komt ie fout terecht.
Ik heb 4 sql tabellen voor me forum
- forum_category
- forum_forum
- forum_topic
- forum_reply
En dus als je een nieuwe topic plaats komt in in de 'forum_topic' tabel. Maar dan wil je bijv daarop reageren en dan pakt ie het 'id' bijv gewoon van de tabel 'forum_reply' maar ik wil graag dat ie bij het gewoon van de tabel 'forum_topic' pakt als de topic pas is geplaats met nog geen reacties.
Wie kan me helpen met het script reply.php ?
<?
$select = "SELECT * FROM forum_reply WHERE id='".$_GET['id']."'";
$query = mysql_query($select);
$list = mysql_fetch_array($query);
echo "<table width=\"70%\" border=\"0\" class=\"content\">".
"<tr>".
"<td align=\"center\" valign=\"top\"><table width=\"99%\">".
"<tr>".
"<td><strong>» <a href=\"index.php\">Welcome on ".$website['name']." Forum</a> » Reply</strong></td>".
"</tr>".
"</table>";
if($_POST['submit']) {
if(empty($_POST['message'])) {
echo "<table class=\"content\" width=\"99%\">".
"<tr><td>You have not filled any message in, <a href=\"javascript:history.go(-1)\">go back</a></td></tr>";
"</table>";
} else {
$topic_id = $list['topic_id'];
$ip = getenv("REMOTE_ADDR");
$host = gethostbyaddr($ip);
$author = $_COOKIE['username'];
$date = date("d-m-Y, H:i");
$message = $_POST['message'];
$update = "UPDATE members SET forum_posts= forum_posts + 1 WHERE username='".$_COOKIE['username']."' AND id='".$_COOKIE['memberid']."'";
$query = mysql_query($update);
$insert = "INSERT INTO forum_reply (topic_id, ip, host, author, date, message) VALUES ('$topic_id', '$ip', '$host', '$author', '$date', '$message')";
$query = mysql_query($insert);
echo "<table class=\"content\" width=\"99%\">".
"<tr><td>The forum has been succesfull saved into the database, <a href=\"index.php?action=forums/topic&id=".$list['topic_id']."&page=1\">go back to the topic</a>.</td></tr>".
"</table>";
}
} else {
echo "<form method=\"post\" name=\"form\">".
"<table width=\"99%\">".
"<tr><td>Message:</td><td>".ubb_buttons("message")."<br><textarea name=\"message\" cols=\"60\" rows=\"8\"></textarea><br>".ubb_smilies("message")."</td></tr>".
"<tr><td></td><td><input type=\"submit\" name=\"submit\" value=\"Submit\"></td></tr>".
"</table>".
"</form>";
}
?>
<? $select = "SELECT * FROM forum_reply WHERE id='".$_GET['id']."'"; echo "<table width=\"70%\" border=\"0\" class=\"content\">". "<tr>". "<td align=\"center\" valign=\"top\"><table width=\"99%\">". "<tr>". "<td><strong>» <a href=\"index.php\">Welcome on ".$website['name']." Forum</a> » Reply</strong></td>". "</tr>". "</table>"; if($_POST['submit']) { if(empty($_POST['message'])) { echo "<table class=\"content\" width=\"99%\">". "<tr><td>You have not filled any message in, <a href=\"javascript:history.go(-1)\">go back</a></td></tr>"; "</table>"; } else { $topic_id = $list['topic_id']; $author = $_COOKIE['username']; $date = date("d-m-Y, H:i"); $message = $_POST['message']; $update = "UPDATE members SET forum_posts= forum_posts + 1 WHERE username='".$_COOKIE['username']."' AND id='".$_COOKIE['memberid']."'"; $insert = "INSERT INTO forum_reply (topic_id, ip, host, author, date, message) VALUES ('$topic_id', '$ip', '$host', '$author', '$date', '$message')"; echo "<table class=\"content\" width=\"99%\">". "<tr><td>The forum has been succesfull saved into the database, <a href=\"index.php?action=forums/topic&id=".$list['topic_id']."&page=1\">go back to the topic</a>.</td></tr>". "</table>"; } } else { echo "<form method=\"post\" name=\"form\">". "<table width=\"99%\">". "<tr><td>Message:</td><td>".ubb_buttons("message")."<br><textarea name=\"message\" cols=\"60\" rows=\"8\"></textarea><br>".ubb_smilies("message")."</td></tr>". "<tr><td></td><td><input type=\"submit\" name=\"submit\" value=\"Submit\"></td></tr>". "</table>". "</form>"; } ?>
|