[Openfirst-cvscommit] forum index.php,1.3,1.4
Brought to you by:
xtimg
From: <i-...@us...> - 2003-10-21 23:03:37
|
Update of /cvsroot/openfirst/forum In directory sc8-pr-cvs1:/tmp/cvs-serv1085/forum Modified Files: index.php Log Message: Added multiple page functionality for thread viewer. Index: index.php =================================================================== RCS file: /cvsroot/openfirst/forum/index.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** index.php 15 Oct 2003 00:50:08 -0000 1.3 --- index.php 21 Oct 2003 21:51:37 -0000 1.4 *************** *** 27,30 **** --- 27,33 ---- */ + //number of threads per page + define("posts_page",10); + include("../config/globals.php"); include($header); *************** *** 189,205 **** if($cat->subforum!=0){ $query = ofirst_dbquery("SELECT ID,Title,Author,DatePosted FROM ofirst_forumposts WHERE forum='".$forum."' AND ReplyTo=0 ORDER BY DatePosted DESC"); ! if(ofirst_dbnum_rows($query)!=0){ echo("<table width=600><tr><th colspan=3>".ucfirst($cat->name)."</th></tr>"); echo("<tr><td class=sub width=400><b>Topic</b></td><td class=sub><b>Author</b></td><td class=sub><b>Date</b></td></tr>"); ! while($post=ofirst_dbfetch_object($query)){ ! if(isset($user)){ ! echo("<tr><td>".getimage($_SESSION["forumvisit".$uname],$post->DatePosted).' <a href="thread.php?id='.$post->ID.'">'.$post->Title."</a></td>"); } ! else{ ! echo('<tr><td><img src=old.png align=absmiddle><a href="thread.php?id='.$post->ID.'">'.$post->Title."</a></td>"); } ! echo('<td><a href="../members/profile.php?id='.urlencode($post->Author).'">'.$post->Author."</a></td>"); ! echo("<td>".$post->DatePosted."</td></tr>"); } echo("</table><br>"); --- 192,237 ---- if($cat->subforum!=0){ + $page=0; + if(isset($_GET["page"])){ + $page=$_GET["page"]-1; + } + if($page<0){ + $page=0; + } $query = ofirst_dbquery("SELECT ID,Title,Author,DatePosted FROM ofirst_forumposts WHERE forum='".$forum."' AND ReplyTo=0 ORDER BY DatePosted DESC"); ! $num=ofirst_dbnum_rows($query); ! if($num!=0){ ! //skip ! for($i=0;$i<$page*posts_page;$i++){ ! if(!ofirst_dbfetch_object($query)){ ! break; ! } ! } echo("<table width=600><tr><th colspan=3>".ucfirst($cat->name)."</th></tr>"); echo("<tr><td class=sub width=400><b>Topic</b></td><td class=sub><b>Author</b></td><td class=sub><b>Date</b></td></tr>"); ! for($i=0;$i<posts_page;$i++){ ! if($post=ofirst_dbfetch_object($query)){ ! if(isset($user)){ ! echo("<tr><td>".getimage($_SESSION["forumvisit".$uname],$post->DatePosted).' <a href="thread.php?id='.$post->ID.'">'.$post->Title."</a></td>"); ! } ! else{ ! echo('<tr><td><img src=old.png align=absmiddle><a href="thread.php?id='.$post->ID.'">'.$post->Title."</a></td>"); ! } ! echo('<td><a href="../members/profile.php?id='.urlencode($post->Author).'">'.$post->Author."</a></td>"); ! echo("<td>".$post->DatePosted."</td></tr>"); ! }else{ ! break; } ! } ! if($num>posts_page){ ! echo("<tr><td class=sub colspan=3 align=right>"); ! if($page>0){ ! echo('<a href="index.php?forum='.$forum.'&page='.($page).'"><<Prev</a> '); } ! echo("Page ".($page+1)." of ".ceil($num/posts_page)); ! if($page<ceil($num/posts_page)-1){ ! echo(' <a href="index.php?forum='.$forum.'&page='.($page+2).'">Next>></a>'); ! } ! echo("</td></tr>"); } echo("</table><br>"); |