quadrant6
01-18-03, 15:36
| Hi, I think it's called 'database paging' in other words limiting the results to a specified # per page and dynamically creating next/previous links accordingly. I used this on a site i created a wee while ago and accomplished it by using SQL LIMIT function Something like: f(!isset($page)){ $page = 1; } $sqlNum = "SELECT stuff FROM table WHERE this = that; $resultNum = mysql_query($sqlNum); $numRows = mysql_num_rows($resultNum); ..... $perPage = 6; $offset = ($page-1)*$perPage; $sql = "SELECT stuff FROM table WHERE this = that LIMIT $offset,$perPage"; This means that you have to run 2 queries instead of 1. It also means that it carries out the query on each page. It would be better if it only had the main query which iw carries out once and then somehow limits the actual output and spreads it accross the pages, perhaps some way of putting the results into arrary or caching etc. If anyone has suggestions please let me know. ? |