Jump to content

SOLVED....


fdark
 Share

Recommended Posts

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 .........

Edited by fdark
Link to comment
Share on other sites

you have to limit the rows number based on page number to show it properly.

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...