View Full Version : pagination

11-20-2006, 02:19 AM
Could someone please help me on a little problem iam having...:thumbsup:

I have a script ye that i need pagination on..ive tryed loads of pagination scripts but still no luk...

iam trying to select links from db thats in a category.....

here is what ive tred up 2 now.

$cat= $_GET[cats];

$query="SELECT * FROM thelinks WHERE catid=$cat";

more paginination code here etc............

$query="SELECT * FROM thelinks WHERE catid=$cat LIMIT $start,$limit";

echo out the pages etc........

but i havnt a clue how to pagaination from a category..like this lol.......

(category)tutorials >> display the links but with pagination

(category)Templates >> display the links but with pagination

my link shud be like this: ?catid=$cats&page=$i

its giving me a head ake because in the mysql i need to use a category aswell....

please help its been bugging me for days..........

SeeIT Solutions
11-20-2006, 12:04 PM
Post all your code so far and the database sructure for thelinks

11-20-2006, 03:24 PM

$num = $_GET['num'];
$num = 1;

$cato = $_GET['catid'];
$cato = 1;

$self = $_SERVER['PHP_SELF'];

$limit = 4;

$start = ($num-1)*$limit;
$start = round($start,0);

$query = "SELECT * FROM thelinks WHERE catid='$cato' LIMIT $start, $limit";
$result = mysql_query($query);

while($res2=@mysql_fetch_array($result)) {

$idlinks = $res2[linkid];
$sitename = $res2[linkname];

echo "<a href=\"fullinfo.php?catid=$cato&linkid=$idlinks\">";

echo $sitename;

echo "</a><br><br>";

$totalpages = mysql_num_rows(mysql_query("SELECT * FROM thelinks WHERE catid='$cato'"));

$totalpages = $totalpages / $limit;
$totalpages = round($totalpages,0);
$c = 0;
echo "<br>";

$page = $c + 1;
echo "[$page] ";
echo "<a href=$self?catid=$cato&num=$page>[$page] </a>";
$c = $c+1;
echo "<br>".$totalpages." Pages in total.";