12-08-2007, 09:22 AM
|
#1 (permalink)
|
|
The Contributor
Join Date: Dec 2007
Posts: 27
Thanks: 0
|
Mod_rewrite & Pagination
Right, this is where I'm at ..
PHP Code:
$total = mysql_query("select count(*) from games where id ='$id'");
$tot = mysql_result($total, 0);
if (is_numeric($_GET['page'])){
$page = $_GET['page'];
}else{
$page = 1;
}
$limit = 1;
$start = ($page * $limit) - $limit;
$query = mysql_query("select * from games where catid = '$id' LIMIT $start, $limit");
I'm just having problems showing the correct links, e.g.
PHP Code:
if ((($start * $page) - $limit) > 0){
$page = $page-1;
echo '<a href="/category/' . $id . '/page-' . $page . '.html">Previous</a>';
$page = $page+1;
}
if (($start * $page) < $tot){
$page = $page+1;
echo '<a href="/category/' . $id . '/page-' . $page . '.html">Next</a>';
$page = $page-1;
}
That works fine, kind of, it shows next and it shows previous, but it never shows them both at the same time, so I only ever get 2 pages of results.
Anyone know why?
|
|
|
|