0

I m trying to do pagination on array in which i m collecting Data..!!!

as i can't use dynamic limit function at stored procedure...!! and without limit pagination cant be possible..!!
so i thought to collect data in a array and put pagination on it....!!!

hope anyone will help me..!!


Thanks..!

4
Contributors
3
Replies
5
Views
8 Years
Discussion Span
Last Post by __avd
1

if you already have your data in an array then you can built it.

$start = $_GET['page']; // yourlink.php?page=0
$items = 5;
for ($i = $start * $items; $i < ($start * ($items + 1)); $i++) {
  // output your $array[$i]
}
0

Hey, P, that's some mean code - beautiful.

You should be able to apply this code to the LIMIT clause in your sql string. The $items is equal to 'y', and the $start * $items is equal to 'x' (let's call it $start_at_this ), in the snippit below:

LIMIT x,y

For example, if you're showing 5 items per page and want to show page 0 (first one), then LIMIT 0,5 will show.

If you want page 1 as your first page, then you'll need to subtract one when creating the $start variable from the $_GET['page'] variable.

$query = "SELECT .... LIMIT {$start_at_this},{$items}";
0

innocent.boys,
Show us your code please. Wrap up source code with bb code tags.

[code=php] ... statements...

[/code]

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.