[Openfirst-cvscommit] forum index.php,1.11,1.12 thread.php,1.9,1.10
Brought to you by:
xtimg
From: Greg I. <i-...@us...> - 2004-04-11 16:48:21
|
Update of /cvsroot/openfirst/forum In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12088/forum Modified Files: index.php thread.php Log Message: Optimized database code Index: thread.php =================================================================== RCS file: /cvsroot/openfirst/forum/thread.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** thread.php 6 Jan 2004 14:54:18 -0000 1.9 --- thread.php 11 Apr 2004 16:34:41 -0000 1.10 *************** *** 26,30 **** * */ ! define("posts_page",10); // Define number of posts to show include("../config/globals.php"); include($header); --- 26,32 ---- * */ ! ! //modify this constant to change the number of posts per page ! define("posts_page",10); include("../config/globals.php"); include($header); *************** *** 106,112 **** echo '<a href="' . $basepath . '/forum/editpost.php?id=' . $msg->ID . '&threadid=' . $thread . '">Edit</a></td></tr></table><br />'; - $query = ofirst_dbquery("SELECT * FROM ofirst_forumposts WHERE ReplyTo=$thread ORDER BY DatePosted"); - $num=ofirst_dbnum_rows($query); - $page = 0; if (isset($_GET["page"])) { --- 108,111 ---- *************** *** 121,125 **** $page = 0; } ! if ($num != 0) { echo('<div><a href="'.$basepath.'/forum/newpost.php?forumid='.urlencode($forum).'&replyto='.$reply.'">New Reply</a></div><br>'); --- 120,128 ---- $page = 0; } ! ! $query = ofirst_dbquery("SELECT * FROM ofirst_forumposts WHERE ReplyTo=$thread"); ! $num=ofirst_dbnum_rows($query); ! $query = ofirst_dbquery("SELECT * FROM ofirst_forumposts WHERE ReplyTo=$thread ORDER BY DatePosted LIMIT " . posts_page . ' OFFSET ' . ($page * posts_page)); ! if ($num != 0) { echo('<div><a href="'.$basepath.'/forum/newpost.php?forumid='.urlencode($forum).'&replyto='.$reply.'">New Reply</a></div><br>'); *************** *** 133,144 **** echo "</th></tr>"; ! // Skip records ! for($i=0; $i < $page * posts_page; $i++) { ! if (!ofirst_dbfetch_object($query)) { ! break; ! } ! } ! for ($i=0; $i < posts_page; $i++) { ! if ($msg=ofirst_dbfetch_object($query)) { echo '<tr><td width=200 valign=top class=sub>' . userdetails($msg->Author) . "<div>Date: $msg->DatePosted</div></td>"; echo "<td valign=top>"; --- 136,140 ---- echo "</th></tr>"; ! while ($msg=ofirst_dbfetch_object($query)) { echo '<tr><td width=200 valign=top class=sub>' . userdetails($msg->Author) . "<div>Date: $msg->DatePosted</div></td>"; echo "<td valign=top>"; *************** *** 164,170 **** } echo '<a href="' . $basepath . '/forum/editpost.php?id=' . $msg->ID . '&threadid=' . $thread . '">Edit</a></td></tr>'; - } else { - break; - } } echo '<tr><th colspan=2><div style="font-size:12px" align=right> '; --- 160,163 ---- Index: index.php =================================================================== RCS file: /cvsroot/openfirst/forum/index.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** index.php 25 Dec 2003 18:52:53 -0000 1.11 --- index.php 11 Apr 2004 16:34:41 -0000 1.12 *************** *** 26,29 **** --- 26,31 ---- * */ + + //modify this constant to change the number of topics per page define("posts_page",10); include("../config/globals.php"); *************** *** 120,133 **** $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 records - 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>"; --- 122,130 ---- $page=0; } ! $query = ofirst_dbquery("SELECT ID FROM ofirst_forumposts WHERE forum='" . $forum . "' AND ReplyTo = 0"); $num = ofirst_dbnum_rows($query); + $query = ofirst_dbquery("SELECT ID,Title,Author,DatePosted FROM ofirst_forumposts WHERE forum='" . $forum . "' AND ReplyTo = 0 ORDER BY DatePosted DESC LIMIT " . posts_page . ' OFFSET ' . ($page * posts_page)); + if ($num != 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>"; |