...

View Full Version : pagination



ab123
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

ab123
11-20-2006, 03:24 PM
<?php
mysql_connect("localhost","user","pass");
mysql_select_db("db");

$num = $_GET['num'];
if(empty($num)){
$num = 1;
}

$cato = $_GET['catid'];
if(empty($cato)){
$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>";

while($c<$totalpages){
$page = $c + 1;
if($_GET['num']==$page){
echo "[$page] ";
}else{//else
echo "<a href=$self?catid=$cato&num=$page>[$page] </a>";
}
$c = $c+1;
}
echo "<br>".$totalpages." Pages in total.";
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum