Adamb10 Posted June 27, 2006 Share Posted June 27, 2006 I added a feature that allows the user to set the # of comments per page the software will show. It appears that that featured broke pagination though. Specifically...this line..[code]$max_results = $row['maxshow'];[/code]Originally $max_results was hardcoded to = 3 but now that its set to whatever is in the DB, not working anymore. Quote Link to comment https://forums.phpfreaks.com/topic/12975-pagination-displays-same-comments-on-every-page/ Share on other sites More sharing options...
.josh Posted June 27, 2006 Share Posted June 27, 2006 right. how about looking at your post and pretending for one moment that you've never seen the rest of the code. do you suppose you could answer your own question, based on what you've provided? Quote Link to comment https://forums.phpfreaks.com/topic/12975-pagination-displays-same-comments-on-every-page/#findComment-49905 Share on other sites More sharing options...
Adamb10 Posted June 27, 2006 Author Share Posted June 27, 2006 haha oops sorry. Wasnt thinking, was watching the baseball game. Heres the code...[code]<?// START MEMORY BUFFERob_start();//index.php//Start the sessionsession_start();//Load required filesrequire('sources/functions.php');//COUNTER STSRT$c_ip = $HTTP_COOKIE_VARS["user_ip"];$counter_file = "sources/counter.txt";$counter_file_line = file ($counter_file);if(!$c_ip) {setcookie("user_ip", $REMOTE_ADDR, time()+360000); $counter_file_line[0]++;$cf = fopen ($counter_file, "w+");fputs($cf, "$counter_file_line[0]"); fclose($cf);}elseif($c_ip != $REMOTE_ADDR){$counter_file_line[0]++; $cf = fopen ($counter_file, "w+");fputs($cf, "$counter_file_line[0]"); fclose($cf);}//END COUNTER//Essential Functionsdb_connect();//Prepare for Query in 5..4..3..2..1function query($query){ $sql = "$query"; $result = mysql_query($sql); return mysql_fetch_array ($result); }// Figure out the limit for the query based// on the current page number.$from = ($page * $max_results); //QUERY START$row = query("SELECT * FROM settings"); //settings query$row1 = query("SELECT * FROM colors"); //colors query$max_results = $row['maxshow'];$q1 = 'SELECT * FROM Bans'; //ban query $r1 = mysql_query($q1) or die(mysql_error()); if($row['postorder'] == "descend") { //Comment Query 1 $q = 'SELECT * FROM comments ORDER BY Date DESC LIMIT '.$from.', '.$max_results.''; $r = mysql_query($q) or die(mysql_error()); } else{if($row['postorder'] == "ascend"){ //Comment Query 2$q = 'SELECT * FROM comments ORDER BY Date ASC LIMIT '.$from.', '.$max_results.''; $r = mysql_query($q) or die(mysql_error()); }}$hf = query("SELECT * FROM hf"); //HF Queryif (!$hf) { die('Invalid query: ' . mysql_error()); }//QUERY END//CSS BEGINecho '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"><head><title>'.$row['title'].'</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/css"><!--a:link { color: #'.$row1['link'].'; text-decoration: none;}a:visited { color: #'.$row1['visitedlink'].'; text-decoration: none;}a:active { color: #'.$row1['activelink'].'; text-decoration: none;}a:hover { color: #'.$row1['hoverlink'].'; text-decoration: none; }body { background-color: #'.$row1['bodybg'].'; font-family: '.$row1['fontfamily'].'; font-size: '.$row1['fontsize'].'; color: #'.$row1['font'].'; margin:0px; ';if ($row1['bodybgimage'] != "") {echo 'background-image: url('.$row1['bodybgimage'].');';}echo ' }.titlebg { background-color: #'.$row1['titlebg'].'; font-family: '.$row1['titlefontfamily'].'; font-size: '.$row1['titlefontsize'].'; color: #'.$row1['titlefont'].'; '; if ($row1['tilebgimage'] == "") { echo ' background-image: url('.$row1['titlebgimage'].');';} echo ' }.windowbg { background-color: #'.$row1['windowbg'].'; font-family: '.$row1['windowfontfamily'].'; font-size: '.$row1['windowfontsize'].'; color: #'.$row1['windowfont'].';'; if ($row1['windowbgimage'] != "") { echo 'background-image: url('.$row1['windowbgimage'].');'; } echo ' }.windowbg2 { background-color: #'.$row1['window2bg'].'; font-family: '.$row1['window2fontfamily'].'; font-size: '.$row1['window2fontsize'].'; color: #'.$row1['window2font'].';'; if($row1['window2bgimage'] != "") { echo 'background-image: url('.$row1['window2bgimage'].');'; } echo ' }.border { background-color: #'.$row1['border'].'; }td { font-size: 11px; }input,textarea { font-family: '.$row1['fontfamily'].'; font-size: 11px; }select { font-family: '.$row1['fontfamily'].'; font-size: 11px; } --!> </style> <title>'.$row1['title'].'</title></head><body>';//CSS ENDif($_GET['action'] == ""){getUserIp();}//echo out the Guestbook Headerguestbook_header();echo '<br><br><br>';require('sources/actions.php');//Check if this really is index.php. if($_GET['action'] == ""){echo '<br>'.$hf['header'].'';if($row['posting'] == "enabled") {if($row['kwikpost'] == "yes"){if($row['kwikpostlocation'] == "top"){kwikpost();}}}}//PAGINATON STARTS HEREif(!isset($_GET['page'])){ $page = 0;} else { $page = $_GET['page'];} echo '<br><br><table style="width: 55%;" class="border" border="0" cellpadding="4" cellspacing="1" align="center">';//COMMENT SYSTEM BEGINif($_GET['action'] == ""){$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM comments"),0);// Figure out the total number of pages. Always round up using ceil()$total_pages = ceil($total_results / $max_results);echo '<center>Select a Page: ';// Build Page Number Hyperlinksif($page > 0){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";}for($i = 0; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; }}// Build Next Linkif($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";}{ while($row = mysql_fetch_array($r)){///END PAGINATION, PROCEED TO NORMAL CODEecho "</center>"; $date = explode("|", $row['date']); $name = $row['name']; $comment = $row['comment']; $email = $row['email']; $website = $row['website']; $hideemail = $row['hideemail'];if(!isset($cmd)){echo ' <tr class="windowbg2"> <td style="width: 27%;">';//HI, WHATS YOUR NAME? echo "$name <br>"; if($hideemail != "o") { echo " <a href=\"mailto: $email\"> [email]</a>"; } if($website != "") { echo "<a href=\"$website\">[website]</a>"; } echo ' </td> <td>'; //DATE SYSTEM $d = $row['date']; $month = date("M"); $day = date("d"); $year = date("Y");//MORE DATESYSTENecho 'Posted on ';if($date['0']==$month && $date['1']==$day && $date['3']==$year){ echo '<b>Today</b>'; } elseif($date['0']==$month && $date['1']==$day-1 && $date['3']==$year){ echo '<b>Yesterday</b>'; } else { echo '<b>'.$date['0'].' '.$date['1'].''.$date['2'].', '.$date['3'].'</b>'; } echo ' at <b>'.$date['4'].'</b>'; }echo "<br><br> $comment </td> </tr>"; }echo '<table><br>';//KWIK POST$row = query("SELECT * FROM settings");if($row['posting'] == "enabled") {if($row['kwikpost'] == "yes"){if($row['kwikpostlocation'] == "bottom"){kwikpost();}}}echo ''.$hf['footer'].''; }}//COMMENT SYSTEM ENDcopyright();// FLUSH MEMORY BUFFER (CLEANER THEN LEAVING IT OUT)ob_flush();?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12975-pagination-displays-same-comments-on-every-page/#findComment-49907 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.