PHP Classes

Query Paginator

Recommend this page to a friend!

      MySQL Query Paginator  >  All threads  >  Query Paginator  >  (Un) Subscribe thread alerts  
Subject:Query Paginator
Summary:Need an example
Messages:2
Author:Vivek Thomas
Date:2012-05-21 02:44:33
Update:2012-05-22 06:43:29
 

  1. Query Paginator   Reply   Report abuse  
Picture of Vivek Thomas Vivek Thomas - 2012-05-21 02:44:33
Can you please post a small example how this programs works and to retrieve the records in html table
using $queryRes = $paginator->getQueryResource();

Thanks,

Vivek

  2. Re: Query Paginator   Reply   Report abuse  
Picture of Adeeyo Sulaiman Adesola Adeeyo Sulaiman Adesola - 2012-05-22 06:41:16 - In reply to message 1 from Vivek Thomas
If I have a table 'members' in my database and i want to be able to browse this members on a page with 30 records per page then i will do the following:

<?php

// You must first of all do the db conn

$sql = 'SELECT * FROM members'

$pagintor = new MaximPaginator(30, $sql);

$vars = get_defined_vars();

$paginator->setDefinedVars($vars);

$query = $paginator->getQueryResource();

?>

<table>

<?php
while($array = mysql_fetch_array($query))
{
?>
<tr> <td><?php echo $array['fullname']; ?>
</td> <td><?php echo $array['email']; ?></td> </tr>
<?php
}
?>
</table>

<?php $paginator->displayNavigator(); ?>

The above code will display a table with 30 records and 2columns of fullname and username. The navigation link will be display below the table with default link-phrase i.e First, Prev, Next, Last. These can be changed using the function customiseNavigation().