<?php

// Actually untested ATM

// Include the paging class
require 'class.paging.php';

// MySQL example
$db mysql_connect('server''user''pass');
mysql_select_db('myDB'$db);

// Get total items
$total mysql_num_rows(mysql_query('SELECT * FROM `table`'));
// Items per page
$perpage 3;
// Create an offset (if not a GET var then 1)
$offset = (isset($_GET['offset']) && is_numeric($_GET['offset'])) ? $_GET['offset'] : 0;

// Instantiate the class
$paging = new paging($total$perpage$offset);

// Only the items we want
$query mysql_query('SELECT * FROM table ORDER BY field DESC LIMIT ' $offset ', ' $perpage);

// If there is more than one page, create a for loop, iterating through the pages
if($paging->pages 1)
{
    echo 
'<p>';
    if(
$paging->current != 1)
    {
        echo 
'<a href="?offset=' $paging->first() . '" title="First page">&lt;&lt;</a> ';
        echo 
'<a href="?offset=' $paging->previous() . '" title="Previous page">&lt;</a> ';
    }
    for(
$i 1$i <= $paging->pages$i++)
    {
        if(
$i == $paging->current)
            echo 
'<em>' $i '</em> ';
        else
            echo 
'<a href="?offset=' $paging->perpage * ($i 1) . '" title="Go to page ' $i '">' $i '</a> ';
    }
    if(
$paging->current != $paging->pages)
    {
        echo 
'<a href="?offset=' $paging->next() . '" title="Next page">&gt;</a> ';
        echo 
'<a href="?offset=' $paging->last() . '" title="Last page">&gt;&gt;</a>';
    }
}

// Echo data in loop
while($data mysql_fetch_array($query))
    echo 
$data['sexual'];

?>