Jump to content

Archived

This topic is now archived and is closed to further replies.

man12_patil3

Pagination by 10-10 page link.

Recommended Posts

php is new lang. for me. i have 2000 record which is dispaly on web page(10 record each page) by pagination. but problem is that i get 200 links of pages on webpage which take large space. I want to display it in a grop of 10-10 pages. where is the code for it.

 

can anybudy help me ??

 

 

Thx 

Share this post


Link to post
Share on other sites

For the first link, put parameters the each link as follows:

 

show.php?min=1&max=10

show.php?min=11&max=20

show.php?min=21&max=30

show.php?min=31&max=40

show.php?min=41&max=50

 

Then in your script, when you fetch the data from the database or text file, ignore all that comes before min and after max values and show the not-ignored values on your website.

 

This means each time you click on a link it makes a new data query.

Share this post


Link to post
Share on other sites

^ You don't need two parameters for each URL, you should do something like:

show.php?page=1

show.php?page=2

...etc

 

Then, with a bit of maths, calculate which records you need for each page on that. Something like:

 

$perpage = 10;
$page = $_GET['page'];

$min = ($page-1)*10;
$max = $min + $perpage;

That will give you min=0, max=10 for page 1; min=10, max=20 for page 2. Then simply use those numbers in your MySQL query, in the "limit" clause. Something like:

 

$sql = "SELECT * FROM mytable LIMIT $min, $max";

 

 

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.