viewing the thread

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

viewing the thread

Post 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
azz0r_
Forum Commoner
Posts: 27
Joined: Mon Jan 24, 2005 4:15 pm

Post by azz0r_ »

Need more detail than that.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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&#1111;2]" class="under">$row&#1111;1]</td><td width=20%>$row&#1111;0]</td></tr>";
			&#125;
			mysql_free_result($result);			
		&#125;
		else
		&#123;
			echo 'system error!<br>'.mysql_error();
		&#125;
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)
		&#123;
			$row = mysql_fetch_array($result, MYSQL_NUM);
			
				echo "<tr><td width=100%>$row&#1111;0]</td></tr>";
				echo "<tr><td width=100%>$row&#1111;1]</td></tr>";
				echo "<tr><td width=100%>$row&#1111;2]</td></tr>";
				echo "<tr><td width=100%>$row&#1111;3]</td></tr>";			
					
		&#125;
		else
		&#123;
			echo 'system error!<br>'.mysql_error();
		&#125;
hope you can help me guys...
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

see how phpBB solves this matter. :wink:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you don't search against a postID, but a topicID.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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?
azz0r_
Forum Commoner
Posts: 27
Joined: Mon Jan 24, 2005 4:15 pm

Post 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.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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&#1111;'pid'];
		require_once('dbconnect.php');
		
		$query = "SELECT title, accomplishment, issue, recommendation FROM posts WHERE postID='$id'";
		$result = @mysql_query($query);
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

n00b Saibot wrote:see how phpBB solves this matter. :wink:
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.
Post Reply