<?php
$url_paginator = 'http://www.site.com.br/produtos';
$paginator = new \Emid\Paginator\Paginator($url_paginator);
$records_per_page = 15;
$number_of_pages = 6;
$offset = ($paginator->get_page() - 1) * $records_per_page;
$query_produtos = mysql_query("SELECT SQL_CALC_FOUND_ROWS pro_id, pro_titulo
FROM tab_produtos
WHERE pro_status = 'A'
LIMIT {$offset}, {$records_per_page}");
$query_produtos_total = mysql_query("SELECT found_rows() AS total");
$row_produtos_total = mysql_fetch_assoc($query_produtos_total);
$paginator->records($row_produtos_total['total']);
$paginator->records_per_page($records_per_page);
$paginator->selectable_pages($number_of_pages);
$paginator->friendlyUrl(true);
while( ... ){
...
}
$paginator->render();
<?php
/* Include path */
set_include_path(implode(PATH_SEPARATOR, array(
__DIR__ . '/../src',
get_include_path()
)));
/* PEAR autoloader */
spl_autoload_register(function ($className)
{
$filename = strtr($className, '\\', DIRECTORY_SEPARATOR) . '.php';
foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
$path .= DIRECTORY_SEPARATOR . $filename;
if (is_file($path)) {
require_once $path;
return true;
}
}
return false;
});