Page 1 of 1
viewing the thread
Posted: Thu Feb 17, 2005 4:55 am
by pleigh
hi there,
i have here a forum like program, i am able to write info to the database, post the title of the thread, made the title a link so it can be viewed, but now i am stuck from here. i have no idea how i can view the thread, i programmed the reportviewer page but unfortunately, i cant view the thread that i'm trying to retrieve...pls help
thanks
pleigh
Posted: Thu Feb 17, 2005 5:26 am
by azz0r_
Need more detail than that.
Posted: Thu Feb 17, 2005 5:38 am
by pleigh
its like this, u saw my thread, i mean, the topic i posted.right?now when u click the topic, you are opening the viewtopic.now, my problem is, im stuck from here, i cannot load or call or get the message from the database to be displayed in the viewtopic page.
this is my query for the display topics:
Code: Select all
$query = "SELECT date, title, postID FROM posts ORDER BY date DESC";
$result = @mysql_query($query);
if ($result)
{
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$post = $rowї2];
echo "<tr><td width=80%><a href="reportviewindex.php?$rowї2]" class="under">$rowї1]</td><td width=20%>$rowї0]</td></tr>";
}
mysql_free_result($result);
}
else
{
echo 'system error!<br>'.mysql_error();
}
sorry, im really stuck.if u want to see my query in the viewtopic page, look at the code below:
Code: Select all
$query = "SELECT title, accomplishment, issue, recommendation FROM posts WHERE postID='(---i'm lost here---)'";
$result = @mysql_query($query);
if ($result)
{
$row = mysql_fetch_array($result, MYSQL_NUM);
echo "<tr><td width=100%>$rowї0]</td></tr>";
echo "<tr><td width=100%>$rowї1]</td></tr>";
echo "<tr><td width=100%>$rowї2]</td></tr>";
echo "<tr><td width=100%>$rowї3]</td></tr>";
}
else
{
echo 'system error!<br>'.mysql_error();
}
hope you can help me guys...
Posted: Thu Feb 17, 2005 5:49 am
by n00b Saibot
see how phpBB solves this matter.

Posted: Thu Feb 17, 2005 8:28 am
by feyd
you don't search against a postID, but a topicID.
Posted: Thu Feb 17, 2005 9:27 am
by s.dot
ultimately the forum topic should have a unique ID, requiring it to be in it's own table. Then when someone posts a reply to that topic, you'd have a field in your reply table perhaps named "topicid" that you would insert the reply to.. for example the topic ID was 87, you'd INSERT INTO replies (topicid, message) values ('87', '$message');
then to load the page thread you'd call all the replies that have a topicid of 87.
At least this is how I do it.
Posted: Thu Feb 17, 2005 9:45 am
by Maugrim_The_Reaper
reportviewindex.php?$row[2]
There supposed to be a variable name before $row[2]?l
Forums are a simple structure. Forum->Topic->Post
To display all posts in a topic - you should have a topic id. Otherwise how are you going to track a thread? Unless your reasoning is a flat forum - no threading. Where only posts need an ID?
Posted: Thu Feb 17, 2005 1:20 pm
by azz0r_
Ok heres how I do it.
You define the threadID in the url, then while through the database getting posts which threadID relates to the url.
Posted: Thu Feb 17, 2005 10:45 pm
by pleigh
hey guys, thanks, i figured it out last night, i changed
reportviewindex.php?$row[2]
to
reportviewindex.php?pid={$row[2]}
then to the handling page, changed thecode from
Code: Select all
$query = "SELECT title, accomplishment, issue, recommendation FROM posts WHERE postID='(---i'm lost here---)'";
$result = @mysql_query($query);
to
Code: Select all
$id = $_GETї'pid'];
require_once('dbconnect.php');
$query = "SELECT title, accomplishment, issue, recommendation FROM posts WHERE postID='$id'";
$result = @mysql_query($query);
Posted: Thu Feb 17, 2005 11:15 pm
by d3ad1ysp0rk
n00b Saibot wrote:see how phpBB solves this matter.

There's times when sending someone to check out pre-existing software helps. This is not one of those times.
phpBB's source is HUGE. If you didn't notice. It took me a long time to be able to look at a random chunk of their code and know what's going on, I don't see how it's going to help him.