View Single Post
Old 05-24-2005   #4 (permalink)
Order
Local Biorust Beast
 
Order's Avatar
 
Join Date: Oct 2003
Location: San Diego, CA, USA
Posts: 2,253

Send a message via AIM to Order Send a message via MSN to Order Send a message via Yahoo to Order
Pagination can get pretty complicated, and is complex.

ParaSnake has the right idea though, you need to have a start and an offset. The start is where to begin, and the offset is how many you want to pull.

This is more of an SQL issue then php, here is some code to generate your links, use the LIMIT SQL statement to limit the results, I am only showing how to generate how many pages you will need.

PHP Code:
$count "SELECT COUNT(*) FROM 'tutorials' WHERE section = '$sec'"// We do not want to limit, since we want a full number.
$res mysql_query($sql);
$count mysql_fetch_array($res);
$pages $count 10// Change 10 to your offset.
$pages ceil($pages); // Rounds it up.
for($i=1;$i == $pages;$i++)
{
   
$count = ($i 10) + // Change the 10 to your offset.
   
echo "<a href='page.php?start=$count&offset=10'>$i</a>"// Change 10 to offset.
}

// Done. 
Not the greatest sample, but is simple.. those will generate your page links, it is up to you to use SQL LIMIT to get the proper results.
__________________
Order is offline