oke, ik ben een soort van forum aan het maken. meer een chat pagina. maar ik zit met een paar kleine probleempjes:
ik ga een keer met een action van een form naar deze pagina terug en dan komt dit
action="gameforum.php?action="' . $_GET['action'] . '"
maar als action 9 moet zijn om te werken komt er in de link '9' te staan waardoor het niet werkt.
wat er ook vaag is, is dat bij de lijst van alle topics alle topics even vaak worde herhaald als het aantal posts die zijn gemaakt. waarom dat is zou ik ook niet weten. dus jullie hulp is erg handig nu.
de code van de pagina staat hieronder:
ps. ik zou het graag in 1 pagina houden als dat mogelijk is. als dat ni kan moete jullie dat maar zeggen
ow en title en content worden gelinkt naar een layout pagina dus in die 2 variabelen staat wat er te zien wordt
<?php
include("../connect.php");
if ( !isset( $_SESSION['clearance'] ) )
{
header("location: ../index.php");
}
//include statusbar with the player array
include ("statusbar.php");
//checks if its a reply
if(!empty($_GET['action']))
{
$title = 'Replys';
//when placed a message put info in database
if ( isset($_POST['replymessage']) )
{
mysql_query("INSERT INTO gameforumreply (gameforum_reply_from, gameforum_reply_time, gameforum_reply_message, gameforum_id)
VALUES('" . $_SESSION['username'] . "','" . time() . "','" . $_POST['replymessage'] . "','" . $_GET['action'] . "')")
or die(mysql_error());
unset($_POST['replymessage']);
header("Location: gameforum.php?action='" . $_GET['action'] . "'");
}
//give the info from replys
else
{
$replys = mysql_query("SELECT * FROM gameforumreply WHERE gameforum_id= '" . $_GET['action'] . "'")or die(mysql_error());
$gettopic = mysql_query("SELECT * FROM gameforum WHERE gameforum_id='" . $_GET['action'] . "'")or die(mysql_error());
$topicinfo = mysql_fetch_array($gettopic);
$content = '<table border =1>
<tr>
<td><div style="width:300px;">' . $topicinfo['gameforum_topic_title'] . '</div></td>
<td><div style="width:150px;">' . $topicinfo['username'] . '</div></td>
<td><div style="width:100px;">' . date("d-m-Y H:i:s",$topicinfo['gameforum_time']) . '</div></td>
</tr>
<tr>
<td colspan="3"><div style="text-align:left;">' . $topicinfo['gameforum_message'] . '</div></td>
</tr>
</table><br />
';
while( $replylist = mysql_fetch_array( $replys ) )
{
$content .= '<table border="1">
<tr>
<td colspan="2">' . $replylist['gameforum_reply_from'] . '</td>
<td>' . date("d-m-Y H:i:s" ,$replylist['gameforum_reply_time']) . '</td>
</tr>
<tr>
<td colspan="3"><div style="text-align:left;width:600px;">' . $replylist['gameforum_reply_message'] . '
</a></div></td>
</tr>
</table><br />
';
}
$content .= '<form name="gameforumreply" method="post" action="gameforum.php?action="' . $_GET['action'] . '"">
New Reply :<br />
<textarea rows="7" cols="60" name="replymessage"></textarea><br />
<input type="submit" value="Place" /><input type="reset" value="empty" />
</form>';
}
}
//end reply
else
//start topic
{
//checks for new topic and adds it in database
if ( isset($_POST['topic']) )
{
mysql_query("INSERT INTO gameforum (username, gameforum_topic_title, gameforum_time, gameforum_message)
VALUES('" . $_SESSION['username'] . "', '" . $_POST['topic'] . "','" . time() . "','" . $_POST['topicmessage'] . "')")
or die(mysql_error());
$last_id = mysql_insert_id();
header("Location: gameforum.php?action='" . $last_id . "'");
}
//else give list for topics with posibility to start one
else
{
$title = 'topics';
//gets title, timefrom topic, time from last reply and the id of topic
$topics = mysql_query("SELECT gameforum.gameforum_topic_title, gameforum.gameforum_time, gameforum.gameforum_id,
gameforumreply.gameforum_reply_time
FROM gameforum, gameforumreply ORDER BY gameforum.gameforum_important DESC,
gameforumreply.gameforum_reply_time DESC, gameforum.gameforum_time DESC")
or die(mysql_error());
$content = '<div style="font-size: 12px;"><table border = "1">';
//makes the list of topics
while( $topiclist = mysql_fetch_array( $topics ) )
{
$content .= ' <tr>
<td><div style="text-align:left;width:500px;"><a href="gameforum.php?action=
' . $topiclist['gameforum_id'] . '">' . $topiclist['gameforum_topic_title'] . '</a></div></td>
</tr>
';
}
$content .= '</table></div>
<br />
<form name="gameforumtopic" method="post" action="gameforum.php">
New Topic :<br />
<input name="topic" type="text" size="70" maxlength="70" /><br />
Message:<br />
<textarea rows="7" cols="60" name="topicmessage"></textarea><br />
<input type="submit" value="Place" /><input type="reset" value="empty" />
</form>';
}
}
include("forumlayout.php");
?>
781 views