fdark Posted March 27, 2011 Share Posted March 27, 2011 hello.....I have problem when I make pagenation....I have 101 total rows in database ...and I using it $rows_per_page = 10;$sql = "SELECT * FROM table";$result = mysql_query($sql, $conn);$total_records = mysql_num_rows($result);$totalpage = ceil($total_records / $rows_per_page);mysql_free_result($result);if ($page < $totalpage) {$pages=$page + 1; echo "<a href='document.php?pages=".$pages."'>Next</a>\n";} I see total pages is 11 and page 11 is appear....but when I using next button or open it is blank ......... Link to comment Share on other sites More sharing options...
birbal Posted March 27, 2011 Share Posted March 27, 2011 you have to limit the rows number based on page number to show it properly. Link to comment Share on other sites More sharing options...
fdark Posted March 27, 2011 Author Share Posted March 27, 2011 I have limited it using if(isset($_GET['pages'])){$pages=$_GET['pages'];}else{ $pages = 0;}$lim = $pages * $rows_per_page;$sql = "SELECT list FROM table LIMIT $start, $rows_per_page";$result = mysql_query($sql, $con);$rows = mysql_num_rows($result);for ($i = 0; $i < $rows; $i++) { $description = mysql_result($result, $i, 0); echo "\$description = $description<br>\n";} I don't know why page 11 is appear...page 11 is blank Link to comment Share on other sites More sharing options...
justsomeguy Posted March 28, 2011 Share Posted March 28, 2011 Where does $start come from? Link to comment Share on other sites More sharing options...
fdark Posted March 29, 2011 Author Share Posted March 29, 2011 I forgot change....$start is $lim.... if(isset($_GET['pages'])){$pages=$_GET['pages'];}else{ $pages = 0;}$lim = $pages * $rows_per_page;$sql = "SELECT list FROM table LIMIT $lim, $rows_per_page";$result = mysql_query($sql, $con);$rows = mysql_num_rows($result);for ($i = 0; $i < $rows; $i++) { $description = mysql_result($result, $i, 0); echo "\$description = $description<br>\n";} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.