xyn Posted July 4, 2007 Share Posted July 4, 2007 Hey! Basically This coding below isnt displaying errors but the problem is I have 2 records within my database, to test the script i wanted to display 1 record per page... which means i would have 2 pages; Well this script shows 1 Records, 1 page. and thats it :S <?php include("../config.php"); ob_start(); session_start(); $dir = $_GET['section']; $id = $_GET['page_id']; $pg = $_GET['page']; include("/home/ascripts/private_files/sql.inc.php"); include("../inc/headers/top.inc.php"); if(!$dir) { // Display the categories. // In two columns. include("home.php"); } elseif(isset($dir) &&!isset($id)) { // Display the specific tutorials for this section // Page them 50 per page. if((!$pg)||($pg == "0")) { $pg = 1; } $limit = 1; $limitval = $pg * $limit - ($limit); $sql_section = mysql_query("SELECT * FROM `Tutorials` WHERE `Section`='".Secure($_GET['section'])."' AND `Approved`='1' ORDER BY `tutorialid` ASC LIMIT $limitval, $limit"); $recordnum= mysql_num_rows($sql_section); if(!mysql_num_rows($sql_section)) { // No records; no tutorials here. echo('no records!'); $nav = "hide"; } else { //records found; display them. while($section = mysql_fetch_array($sql_section)) { //display the tutorials } } if($pg == "1") { $previous = "[ Previous"; }else{ $pgpast = $pg-1; $previous = "[ <a href=\"/tutorials/index.php?section=$dir\">Previous</a>"; } $totalrecords = floor($recordnum / $limit); for($i=0; $i<=$recordnum; $i++) { if($i == "0") { $pages.= ""; } elseif($i == $pg) { $pages.= " | $i"; } else { $pages.= " | <a href=\"/tutorials/index.php?section=$dir&page=$i\">$i</a>"; } } if(($recordnum - ($limit * $pg)) >0) { $pgnext = $pg+1; $next = " | <a href=\"/tutorials/index.php?section=$dir&page=$pgnext\">Next</a> ]"; } else { $next = " | Next ]"; } if($nav != "hide") { echo("<p align=\"center\">" . $previous . $pages . $next . "</p>"); } } elseif(isset($dir) &&isset($id)) { // Now lets display the tutorial. echo("Tutorial display: ".$id); } else { include("../404.php"); } include("../inc/headers/bottom.inc.php"); ob_end_flush(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/58434-solved-pagination-problems/ Share on other sites More sharing options...
xyn Posted July 4, 2007 Author Share Posted July 4, 2007 Ok, the problem is here... $totalrecords = floor($recordnum / $limit); for($i=0; $i<=$totalrecords; $i++) { if($i == "0") { $pages.= ""; } elseif($i == $pg) { $pages.= " | $i"; } else { $pages.= " | <a href=\"/tutorials/index.php?section=$dir&page=$i\">$i</a>"; } } I'm lsot for ideas though :S Quote Link to comment https://forums.phpfreaks.com/topic/58434-solved-pagination-problems/#findComment-289758 Share on other sites More sharing options...
sasa Posted July 4, 2007 Share Posted July 4, 2007 you $recordnum = $limit => number of pages is 1 you must count all records without limit part $recordnum = mysql_result(mysql_query("SELECT count(*) FROM `Tutorials` WHERE `Section`='".Secure($_GET['section'])."' AND `Approved`='1' "),0,0); Quote Link to comment https://forums.phpfreaks.com/topic/58434-solved-pagination-problems/#findComment-289763 Share on other sites More sharing options...
xyn Posted July 4, 2007 Author Share Posted July 4, 2007 Thanks; But i fixed it by replacing floor(); with ceil(); Quote Link to comment https://forums.phpfreaks.com/topic/58434-solved-pagination-problems/#findComment-289769 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.