Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sliding pager 4

Status
Not open for further replies.

leegold2

Technical User
Oct 10, 2004
116
0
0

I think I want sliding if that means the pager will show maybe 10 page links per page ie. like google. The the next ten, then the next ten forwards and back...
I've looked the PEAR object but I want just non Object Oriented ie. "standard" code.

I already have pagination but I want to make it sliding. I'd prefer to just add to want I have now - so my question is:

What is the code or psedo-code to do this? How do you group them like that? Basically what's the trick?

Thnaks
 
Try telling us what data you are wanting to display and where it's from.

If it's database entries you can restrict your record set in the SQL command, if not you can use arrays. There are many solutions to this kind of thing but it's difficult to give one without the problem being defined well.
 
If you mean like google, paged listing, use LIMIT in the sql query (if you have one, that is), as figmatalan said above..

ORDER BY type
LIMIT '{$start}', '{$stop}'

you also need some $perpage = 10; or whatever, to calculate where to start and where to stop.

when parsing the paged listing links, you need to calculate...
 
I think what he is after is a paging system where the start floats along with the depth of the recordset being returned

ie

on the first page there are links

[1] [2] [3] [4] [5] [next]

then on the third page

[home] [2] [3] [4] [5] [6] [next]

and so on

Bastien

Cat, the other other white meat
 
bastien: this is what I talked about: paged listing.

You make a paged listing by LIMIT'ing the query, as figmatalan stated too.

you put variables in the LIMIT query, instead of constant limits, so the user can control where the limit should start and end.

you simply get the num_rows, set a $perpage and then you are on the go.

make a loop, which generates the links, with a variable $start or something.

the script then knows that it should limit from $start to $stop ($stop = $start + $perpage)

 
ohoi pirate!

I got what ye be wantin'
Code:
<?php
$start = 0; // always 0!!
$perpage = 10; // how many you want to display per page
$numrows = 187; // fill this with mysql_num_rows($result);

while ($start < $numrows) // loop
  {
    if ($numrows < $start + $perpage) // if start + perpage is more than the number of rows
      {
        $stop = $numrows; // set it to stop at number of rows
      }
    else // increase with perpage
      {
        $stop = $start + $perpage;
      }
    echo $start . " - " . $stop. "<br />"; // test parse
    $start = $start + $perpage;
  }
?>
 
Thank you for all the help -I appreciate the support.

To this post:
"ericbrunson (TechnicalUser) Oct 14, 2004
Quote:
I want just non Object Oriented ie. "standard" code
What a silly statement."

Sorry, but I have that requirement.
 
DaButcher

Yes, I realize that is what you were talking about, I was just trying to clarify what leegold was truly after.

Anyhow, (s)he's got it fixed, so kudos to us all

Bastien

Cat, the other other white meat
 
Not yet. In about a week, I will have time to implement this pager - thought I'd have time. I appreciate the help - thank you again!
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top