I have a function that accepts a page number and an amount per page value then generates the numbers for the LIMIT clause. It requires SQL_CALC_FOUND_ROWS to be specified in the query.
iNum=10; // Rows per page iPage=1; // Current page, first page is 1 iStart= (iPage-1) * iNum; // Starting row number Run the query ::SELECT SQL_CALC_FOUND_ROWS FROM ... LIMIT iStart,iNum;:: iFoundRows = ::SELECT FOUND_ROWS();:: iTotalPages = ceil(iFoundRows / iNum); // Total number of displayable pages; >From there you can determine what sort of data you want to display (like every 5th page, etc.) Note: SQL_CALC_FOUND_ROWS/FOUND_ROWS() was introduced in 4.0, to get the total number of rows prior to 4.0 I believe you had to run the same query without the LIMIT clause and use the number of rows returned. This is the best way I have found to do this, you could do a google search for 'MySQL paginate' to get more info. If anyone else has a better way to do this I'd like to hear it... Chris -----Original Message----- From: Mike Blezien [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 12, 2003 6:11 PM To: MySQL List Subject: Page Numbers Hello, we've set up many displays using the "Previous" and "Next" simple linking set up of search results. But now would like to implement the page number style, IE. "Previous" [1] [2] [3] "Next" style format and was hoping someone may have a sample/example queries to accomplish this. Usually working with 10 results per page display. TIA -- Mike<mickalo>Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com Quality Web Hosting http://www.justlightening.net MSN: [EMAIL PROTECTED] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]