spike232 Posted February 3, 2003 Share Posted February 3, 2003 i have a page which displayes records from a mysql database, but i want to limit it to only 10 records and then beable to advance trhoguth them in sets of 10, anyone know where i can find some example code of this? or a better idea of how to do it Link to comment Share on other sites More sharing options...
0 pinky Posted February 3, 2003 Share Posted February 3, 2003 $limit= records per page $pn=page user requested $pages = number of pages from a full query "SELECT count(whatever) as count FROM table WHERE blah; //This query just got us the total number or records found $pages = ceil($result_of_query / $limit); //Set up the start point for archives, eg article 1,25,50,75,etc. $start = $pn * $limit - $limit $query = "SELECT * FROM table WHERE blah LIMIT " . $start . "," . $limit; //This gets you the selected records from 1-10, 11-20, whatever That's it...just print out the page pagination on the page and you're done. Edit: Here's the pagination too for ($loopcount = 1; $loopcount <= $pages; $loopcount++) { echo "<a href='/link/to/page.php?pn=$loopcount'>"; } Link to comment Share on other sites More sharing options...
0 spike232 Posted February 3, 2003 Author Share Posted February 3, 2003 thanks :) Link to comment Share on other sites More sharing options...
Question
spike232
i have a page which displayes records from a mysql database, but i want to limit it to only 10 records and then beable to advance trhoguth them in sets of 10,
anyone know where i can find some example code of this? or a better idea of how to do it
Link to comment
Share on other sites
2 answers to this question
Recommended Posts