Hi im working on this forum now for like 4 vecks and it still cant get it to work.....
The problem is that when i select a topicID to go to it works fine but the problem is that i want all the post to be in the right topicid order......
Now i have manage to find the error but i do not know how to solve it,,,
The problem is that it dosent echo a TopicID after function.php and tha means that every thing just gets in the same sight!!
Sow far has nowbody figured ut how to solve it if the is som one
ihop some guru can help me with this one!
here are three files..
first file .. index.php
<?php
require( './functions.php');
showheader("Flamelines Topics");
?>
<TABLE BORDER=0 WIDTH=100% CELLSPACING=3 CELLPADDING=5>
<TR>
<TD>
<FONT COLOR="#000000" FACE="Arial,Verdana,Helvetica" size=-1>
<b>Forum Topics Bord: </b>
<BR>
<P>
<a href="add-topic.php"><FONT COLOR="#000000">Click here to make a topic</a>
</TD>
</TR>
</TABLE>
<P>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
<TR VALIGN=TOP ALIGN=LEFT>
<TD WIDTH=100%>
<TABLE BORDER=0 BGCOLOR="#000000" CELLSPACING=1 CELLPADDING=1 WIDTH=100%>
<TR>
<TD BGCOLOR="#C0C0C0" WIDTH=100%>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100%>
<TR>
<TD>
<P><B><FONT COLOR="#000000" FACE="Trebuchet MS,Arial,Helvetica">Flamelines Topics</FONT></B>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<?php
$topic_query = mysql_query("SELECT * FROM topics ORDER BY ID") or die (mysql_error());
while ($topic = mysql_fetch_array($topic_query)) {
?>
<TR>
<TD WIDTH=82% BGCOLOR="#FFFFFF" HEIGHT=28 VALIGN=TOP>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100%>
<TR>
<TD>
<P><FONT SIZE="+1" FACE="Trebuchet MS,Arial,Helvetica"><a href="view.php?topicID=<?php echo $topic['ID'] ?>"><?php echo $topic['TopicName'] ?></a></FONT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<?php
}
if (mysql_num_rows($topic_query) < 1) {
?>
<TR height=300>
<TD WIDTH=100% BGCOLOR="#FFFFFF" HEIGHT=28 VALIGN=TOP>
<CENTER><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">
<BR><B>There Are No Topics</B><BR><BR></CENTER>
</TD>
</TR>
<?php } ?>
</TABLE>
</TD></TR>
</TABLE>
<?php
showfooter();
?>
and the second file view.php
<?php
require( './functions.php');
viewpost ($topicID);
?>
And the last file... functions.php
<?php
mysql_connect("**","","");
mysql_select_db("**");
function showheader($title) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE> <?php echo $title ?> </TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?php
}
function showfooter() {
?>
</BODY>
</HTML>
<?php
}
function viewpost ($topicID) {
$topic_query = mysql_query("SELECT topicname FROM topics WHERE ID='$topicID'") or die (mysql_error());
$topic = mysql_fetch_array($topic_query);
?>
<TABLE BORDER=0 WIDTH=100% CELLSPACING=3 CELLPADDING=5>
<TR>
<TD>
<FONT COLOR="#000000" FACE="Arial,Verdana,Helvetica" size=-1>
<b>Flameline Forum Bord</b>
<BR><?php echo $topic['TopicName'] ?>
<P>
<a href="index.php"><FONT COLOR="#000000">Return back to flamelines topics List</a>
<P>
<a href="add-post.php?topicID=<?php echo $topicID?>"><FONT COLOR="#000000">Make a new post</a>
</TD>
</TR>
</TABLE>
<P>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
<TR VALIGN=TOP ALIGN=LEFT>
<TD WIDTH=100%>
<TABLE BORDER=0 BGCOLOR="#000000" CELLSPACING=1 CELLPADDING=1 WIDTH=100%>
<TR>
<TD COLSPAN=3 BGCOLOR="#C0C0C0" WIDTH=100%>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100%>
<TR>
<TD>
<P><B><FONT COLOR="#000000" FACE="Trebuchet MS,Arial,Helvetica">Topic Posts</FONT></B>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<?php
// Läger upp postsen i ordning
$post_query = mysql_query("SELECT * FROM posts WHERE (TopicID='$topicID') ORDER BY TimeStamp") or die (mysql_error());
while ($post = mysql_fetch_array($post_query)) {
?>
<TR>
<TD WIDTH=82% BGCOLOR="#FFFFFF" HEIGHT=28 VALIGN=TOP>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100%>
<TR>
<TD>
<P><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica"><?php echo $post['Post'] ?></FONT>
</TD>
</TR>
</TABLE>
</TD>
<TD WIDTH=18% BGCOLOR="#C0C0C0" VALIGN=TOP>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100% >
<TR>
<TD>
<P ALIGN=center><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica" color=#000000>Posted By: <A HREF="mailto:<?php echo $post['Email'] ?>"> <FONT COLOR=#000000><?php echo $post['Name'] ?></A>
<BR><BR>
<A HREF="edit-post.php?postID=<?php echo $post['ID'] ?>"><FONT COLOR=#000000>Edit Your Post</FONT>
<BR><BR>
<A HREF="delete-post.php?postID=<?php echo $post['ID'] ?>"><FONT COLOR=#000000>Delete Your Post</FONT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<?php
}
if (mysql_num_rows($post_query) < 1) {
?>
<TR height=300>
<TD WIDTH=100% BGCOLOR="#FFFFFF" HEIGHT=28 VALIGN=TOP colspan=2>
<CENTER><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">
<BR><B>There Are No Posts Currently For This Topic</B><BR><BR></CENTER>
</TD>
</TR>
<?php } ?>
</TABLE>
</TD></TR>
</TABLE>
<?php
}
// Lägger till en post
function addpost () {
global $password,$email,$name,$post,$topicID;
$timestamp = time();
$new_password = addslashes($password); $new_email = addslashes($email);
$new_name = addslashes($name);
$new_post = addslashes(nl2br(htmlspecialchars($post)));
$insert = mysql_query("INSERT INTO posts VALUES ('NULL','$topicID','$new_name','$new_email','$new_password','$timestamp','$new_post')");
if (mysql_error() != "") {
showheader("MySQL Error ".mysql_error());
?>
<br><p><center><b>There was a MySQL Error -- <?php echo mysql_error() ?></b></center></p>
<?php
showfooter();
exit;
}
}
// Editerar en post
function editpost () {
global $postID,$post;
$new_post = addslashes(nl2br(htmlspecialchars($post)));
$insert = mysql_query("UPDATE posts SET post='$new_post' WHERE (ID='$postID')");
if (mysql_error() != "") {
showheader("MySQL Error ".mysql_error());
?>
<br><p><center><b><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">There was a MySQL Error -- <?php echo mysql_error() ?></b></center></p>
<?php
showfooter();
exit;
}
}
// Tar bort en post
function deletepost () {
global $postID;
$post_query = mysql_query("DELETE FROM posts WHERE (ID='$postID')");
if (mysql_error() != "") {
showheader("MySQL Error ".mysql_error());
?>
<br><p><center><b><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">There was a MySQL Error -- <?php echo mysql_error() ?></b></center></p>
<?php
showfooter();
exit;
}
}
// Lägger upp en topic
function addtopic () {
global $topicname;
$new_topicname = addslashes($topicname);
$topic_query = mysql_query("INSERT INTO topics VALUES ('NULL','$new_topicname')");
if (mysql_error() != "") {
showheader("MySQL Error ".mysql_error());
?>
<br><p><center><b><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">There was a MySQL Error -- <?php echo mysql_error() ?></b></center></p>
<?php
showfooter();
exit;
}
return mysql_insert_id();
}
?>