tags:

views:

49

answers:

2

This is my script which i have used to paginate ,,The datas are restricted to 4 but the pagination link doesn't appear

<? 
require_once ('Pager/Pager.php');
$connection = mysql_connect( "localhost" , "root" , "" );
mysql_select_db( "ssit",$connection);
$result=mysql_query("SELECT dFrindName FROM tbl_friendslist", $connection);
$row = mysql_fetch_array($result);
$totalItems = $row['total'];
$pager_options = array(
'mode'       => 'Sliding',   // Sliding or Jumping mode. See below.
'perPage'    => 4,   // Total rows to show per page
'delta'      => 4,   // See below
'totalItems' => $totalItems,
);
$pager = Pager::factory($pager_options);
echo $pager->links;
list($from, $to) = $pager->getOffsetByPageId();
$from = $from - 1;
$perPage = $pager_options['perPage'];
$result = mysql_query("SELECT * FROM tbl_friendslist LIMIT 5 , $perPage",$connection);
while($row = mysql_fetch_array($result))
{
echo $row['dFrindName'].'</br>';
}
?>
+1  A: 

The query you're using doesn't have total defined. Try:

$result=mysql_query("SELECT dFrindName, COUNT(dFrindName) AS total FROM tbl_friendslist GROUP BY dFrindName", $connection);
Jonathan
@Jonathon the data's are limited but the link doesnt appearex:1 2 3 nextThis doesnt appear for me
udaya
what does $row['total'] contain?
Jonathan
+1  A: 

Since you use mysql_fetch_array not in a loop, you only fetch the latest dataset. I think you have to use mysql_num_rows as total-value:

...
$result=mysql_query("SELECT dFrindName FROM tbl_friendslist", $connection);
$totalItems = mysql_num_rows($result);
...
faileN
@faileN : It works
udaya