Hey Matthew -

The Smarty Template Engine (http://smarty.php.net/) plus some quick 
adjustments to your query works great.
There's a Smarty Plugin that ships with it called SmartyPaginate that 
takes care of all that stuff for you.

You just need to capture Limit and Offset values (Limit probably from a 
preference file or constant in your script) and Offset -- typically as a 
GET parameter.

For your query, you just do:
SELECT * FROM whatever LIMIT <number of records per page> OFFSET <number 
of records offset from zero>

If you're doing something where the data doesn't change much, you might 
want to check out the PEAR module Cache::Lite.  It caches the output of 
those pages so you're not nailing the database every time you want to 
display a page.  You can set a time limit on the cache, so you're only 
hitting the database once every so many seconds.  It's easy to slap 
around a script once you get it working, and it's another five or six 
lines of code. 

I'm using it on some production stuff that gets millions of daily 
pageviews (and has very expensive queries, but relatively static data).  
The load on the server is negligible, with the bonus that it speeds up 
the results presented to the user. 95% of the time, we're not even 
connecting to the database.

-Jeromie

>--- Matthew Hackett <[EMAIL PROTECTED]> wrote:
>
>  
>
>>i know this is a php / mysql list but i'm coming to the end of my
>>tether!
>>
>>Anyone have any ideas or code snippets for Pagination (i.e. < PREV 1 2 3
>>4 NEXT > ) when using a query on an MS SQL database?
>>    
>>
>
>Without knowing any real specifics about MSSQL, I can tell you that this
>sort of thing is typically accomplished on MySQL systems using queries
>that include the LIMIT clause.
>
>SELECT * FROM tbl_name WHERE col=value LIMIT 5,10
>
>This gets all information from the table tbl_name where the column named
>'col' has a value of 'value', starting at the 6th row (5 is row six, the
>numbering starts at 0) and returns 10 rows.
>
>So, you would just need to change the numbers in the LIMIT clause to
>create the links for "PREV", "1", etc.
>
>
>
>Michael Roush
>[EMAIL PROTECTED]
>
>"The power of the Web is in its universality. Access by everyone regardless of 
>disability is an essential aspect." 
>-- Tim Berners-Lee, W3C Director and inventor of the World Wide Web
>
>
>       
>               
>______________________________________________________ 
>Yahoo! for Good 
>Donate to the Hurricane Katrina relief effort. 
>http://store.yahoo.com/redcross-donate3/ 
>
>
>
>
>The php_mysql group is dedicated to learn more about the PHP/MySQL web 
>database possibilities through group learning.  
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>  
>



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/CefplB/TM
--------------------------------------------------------------------~-> 

The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




Reply via email to