Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 3:36 PM   #1
David & Angela Ehmer
 
David & Angela Ehmer's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default forum display

I have developed a forum at:
http://www.acpchnqld.org.au/forum/forum.php

The initial list does not have a method for displaying the previous posts at
this stage. I would like a row at the bottom of the list to provide
relevant links for 'older messages' and/or 'newer messages'.

The code I think may provide this is;
if (!$result){
$num_msgs = mysql_numrows($result);
$prev = $next - $rpp;
$next += $rpp;
echo"<tr><td colspan='3' bgcolor = '#EEF5FE' align = right>";
if($next <= $num_msgs)echo"<a href=\"forum.php?next=$next\">Older
Messages</a>";
if(($next <= $num_msgs) && ($prev >= 0))echo"&nbsp;&nbsp;|&nbsp;&nbsp;";
if($prev >= 0)echo"<a href=\"forum.php?next=$prev\">Newer Messages</a>";
echo"</td></tr>";
}

However I've tried to place this code within the structure of the list and
can only make it appear at the top of the list. Also the parameters being
passed in the URL (eg next=20) don't have any effect on the display,
effectively being ignored. I'm unsure why this is.

The full code for this file is below. Appreciate any suggestions
Thanks
David

FULL CODE:
<?
// functions for loading, contructing and
// displaying the tree

class treenode
{
// each node in the tree has member variables containing
// all the data for a post except the body of the message
var $m_postid;
var $m_title;
var $m_poster;
var $m_posted;
var $m_children;
var $m_childlist;
var $m_depth;

function treenode($postid, $title, $poster, $posted, $children,
$expand, $depth, $expanded, $sublist)
{
// the constructor sets up the member variables, but more
// importantly recursively creates lower parts of the tree
$this->m_postid = $postid;
$this->m_title = $title;
$this->m_poster = $poster;
$this->m_posted = $posted;
$this->m_children =$children;
$this->m_childlist = array();
$this->m_depth = $depth;

// we only care what is below this node if it
// has children and is marked to be expanded
// sublists are always expanded
if(($sublist||$expand) && $children)
{
$conn = db_connect();

if(!$next){ $next=0;
}

$rpp = 20;//results per page
$query = "select * from header where parent = $postid order by posted
desc limit $next, $rpp";
$result = mysql_query($query);

for ($count=0; $row = @mysql_fetch_array($result); $count++)
{
if($sublist||$expanded[ $row['postid'] ] == true)
$expand = true;
else
$expand = false;
$this->m_childlist[$count]= new
treenode($row['postid'],$row['title'],
$row['poster'],$row['posted'],
$row['children'], $expand,
$depth+1, $expanded, $sublist);
}
}
}

function display($row, $sublist = false)
{
// as this is an object, it is responsible for displaying itself
// $row tells us what row of the display we are up to
// so we know what color it should be
// $sublist tells us whether we are on the main page
// or the message page. Message pages should have
// $sublist = true.
// On a sublist, all messages are expanded and there are
// no "+" or "-" symbols.
// if this is the empty root node skip displaying
if($this->m_depth>-1)
{
//color alternate rows
echo "<tr><td bgcolor = ";
if ($row%2)
echo "'#EEF5FE'>";
else
echo "'#ffffff'>";

// indent replies to the depth of nesting
for($i = 0; $i<$this->m_depth; $i++)
{
echo "<img src = 'images/spacer.gif' height = 12
width = 10 alt = '' valign = bottom>";
}

// display + or - or a spacer
if ( !$sublist && $this->m_children && sizeof($this->m_childlist))
// we're on the main page, have some children, and they're expanded
{
// we are expanded - offer button to collapse
echo "<a href = 'forum.php?collapse=".
$this->m_postid."#$this->m_postid'
><img src = 'images/minus.gif' valign = bottom

height = 9 width = 9 alt = 'Collapse Thread' border = 0></a>";
}
else if(!$sublist && $this->m_children)
{
// we are collapsed - offer button to expand
echo "<a href = 'forum.php?expand=".
$this->m_postid."#$this->m_postid'><img src = 'images/plus.gif'
height = 9 width = 9 alt = 'Expand Thread' border = 0></a>";
}
else
{
// we have no children, or are in a sublist, do not give button
echo "<img src = 'images/spacer.gif' height = 9 width = 9
alt = ''valign = bottom>";
}

echo " <a name = $this->m_postid >
<a href = 'view_post.php?postid=$this->m_postid'>$this->m_title </td>
<td class='forumtext' bgcolor = ";
if ($row%2) {
echo "'#EEF5FE'>";
}
else{
echo "'#ffffff'>";
}

echo "$this->m_poster</td><td class='forumtext' bgcolor = ";
if ($row%2) {
echo "'#EEF5FE'>";
}
else{
echo "'#ffffff'>";
}
echo "".reformat_date($this->m_posted)."</a>";
echo "</td></tr>";

// increment row counter to alternate colors
$row++;
}
// call display on each of this node's children
// note a node will only have children in its list if expanded
$num_children = sizeof($this->m_childlist);
for($i = 0; $i<$num_children; $i++)
{
$row = $this->m_childlist[$i]->display($row, $sublist);
}
return $row;
}
};
?>


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
dvd player mp3 ID3 TAG display Tobias.Kuechen@gmx.de Car audio 1 06-18-2007 2:40 PM
Freelander Display Gareth Watkins Car audio 0 06-17-2007 7:37 PM
Greyscale display Colin Cook Operating Systems And Software 0 05-29-2007 12:54 AM
WDS Display Problem... NewMan MSN questions 1 05-28-2007 1:44 AM
Forum Posters Required for my Forum Posting Service Company mayank For Hire 6 05-12-2006 10:11 AM


Featured Websites




All times are GMT +1. The time now is 3:09 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98