Forums

PHP

This topic is locked

Pagination Help Pls

Posted 03 Aug 2006 07:21:20
1
has voted
03 Aug 2006 07:21:20 Tyger Burch posted:
I got this code and I had to attempt to make some changes to it because either my version of MySQL wouldn't accept it in the form it was given to me or it had errors in it to begin with. Not sure which one is true. What I do know is when I finally got it CLOSE to working I noticed that it wold not transition to the next page. the links appear but they don't bring up a new page. Can someone please help out, kinda desperate here.


<?
include('dbconnect.php');//include the file to connect to the database

if ( $_GET['number'] == NULL ){
$limit = 1;
} else {
$limit = $_GET['number'];
}

if ($_GET['page']==NULL){
$start = 0;
} else {
$start = $_GET['page'];
}

if($_GET[‘page’] < 0){
header('Location: index.php?page=0&limit='.$limit);
}

$getcat = mysql_query('SELECT * FROM catalog LIMIT ' .$start. ' , ' .$limit) or die(mysql_error());

while($r=mysql_fetch_array($getcat)){
$id = $r['id'];
$name = $r['name'];
$price = $r['price'];
extract($r);//remove the $r so its just $variable

echo("<a href='themes/".($id)."'><img style='border:solid; border-color: #000000;' src='/thumbs/".($id).".jpg' alt='thumb'/></a><br />
<font size=2>$$price</font></font><br>"
);
}

$previous = $start + $limit;
$next = $start - $limit;
echo ("<a href='test.php?start=".$previous."'>Previous Page</a> - ";
echo ("<a href='test.php?start=".$next."'>Next Page</a>";

?>

Reply to this topic