El problema que tengo es que el paginador, me muetra en la pagina << 1, 2 , 3 >>, todas las paginas y andan, pero el problema que no puedo hacer que muestre de a 5 cargas por hoja, abajo les dejo el codigo de paginador.php y los codigos incorporados en doc.php para el que me pueda dar una mano, gracias
paginador.php
-----------------------------------------------------
<?php
// Clase de paginacion
class Paging
{
// Varibles to be uses as Menu Config
// If not set with the proper Function
// they get a default Value
/* How Many result Per Page
@INT
*/
var $perPage;
/* String with the next Link-Text
@STR : Can be html to use images <img src="img/next.gif" alt="next">
*/
var $strNext;
/* String with the next Link-Text
@STR : Can be html to use images <img src="img/next.gif" alt="next">
*/
var $strPrev;
/* String with the Var name that will be used for Paging
@STR : Use Only [a-z][A-Z] Chars Please (DO NOT INCLUDE [0-9]
*/
var $varName;
// Variables For Calculation Of Result
/* Variable that Holds The Number Of Results In the Query
@INT
*/
var $total;
/* Total Number Of Pages
$INT
*/
var $totalPages;
/* Variable that Holds the number of the begibib in the query
@INT
*/
var $start;
/* THe current Value of $_GET[ $varName ]
@INT
*/
var $page;
// Variables for Storing Mysql Querys And Results
/* This Variable Holds the Original Query Of the User
@STR
*/
var $sql;
// Class Constructor PASS the query
// Only Selects
function Paging($sql)
{
// Store the Original SQL
$this->sql = $sql;
// Get The SQL Count Query String
$sqlCount = eregi_replace("select (.*) from", "SELECT COUNT(*) FROM", $this->sql);
// Fetch the Result
$sqlCount = mysql_query($sqlCount);
// Set the Total
$this->total = mysql_result($sqlCount,0,0);
}
// Method Used Internaly to Propage the URL GET Variables
function propagate(&$a,$pref='',$f='',$idx='')
{
$ret = '';
foreach ($a as $i => $j)
{
if ($i != $this->varName)
{
if ($idx != '')
{
$i = $idx."[$i]";
}
if (is_array($j))
{
$ret .= $this->propagate($j,'',$f,$i);
}
else
{
$j=urlencode($j);
if (is_int($i))
{
$ret .= "$f$pref$i=$j";
}
else
{
$ret .= "$f$i=$j";
}
}
}
$f='&';
}
return $ret;
}
// Methods For Configuration
function set_perPage($value)
{
$this->perPage = $value;
}
function set_strNext($value)
{
$this->strNext = $value;
}
function set_strPrev($value)
{
$this->strPrev = $value;
}
function set_varName($value)
{
$this->varName = $value;
}
function sysConfig()
{
// This Method Calls All all the Config Methods
// To configure the Class
if (empty($this->varName))
{
$this->set_varName('page');
}
if (empty($this->strPrev))
{
$this->set_strPrev('<< ');
}
if (empty($this->strNext))
{
$this->set_strNext(' >>');
}
if (empty($this->perPage))
{
$this->set_perPage(10);
}
$this->page = isset($_GET[$this->varName] ? $_GET[$this->varName] : 1;
$this->totalPages = ceil($this->total / $this->perPage);
$this->start = ($this->page - 1) * $this->perPage;
}
function getMenu()
{
// Config CALL
$this->sysConfig();
$string = $this->propagate($_GET);
$more = $this->page + 1;
$less = $this->page - 1;
if ($this->page != 1)
{
$navResult[] = "<a href=\"$_SERVER[PHP_SELF]?$string&$this->varName=$less\">$this->strPrev</a>";
}
for ($i=1;$i<=$this->totalPages;$i++)
{
$navResult[] = ($this->page == $i) ? " <strong>$i</strong> " : "<a href=\"$_SERVER[PHP_SELF]?$string&$this->varName=$i\">$i</a>";
}
if ($this->page != $this->totalPages)
{
$navResult[] = "<a href=\"$_SERVER[PHP_SELF]?$string&$this->varName=$more\">$this->strNext</a>";
}
$navResult = implode($navResult,' | ');
$navResult = "Mostrando Pagina $this->page de $this->totalPages - $this->total Registros<br/>" .$navResult;
return $navResult;
}
function getResult()
{
$this->sysConfig();
$this->sql .= " LIMIT $this->start, $this->perPage";
$result = mysql_query($this->sql);
return $result;
}
function debug()
{
echo '<textarea cols="60" rows="10">';
print_r($this);
echo '</textarea>';
}
}
?>
-------------------------------------------------------------------------
y doc.php que tiene codigo php incorporado:
<?
//if($seccion == 0)
$query = "SELECT * FROM catalogo WHERE seccion_ita = 'Documentari' AND estado = 1 ORDER BY 1";
//else
//$query = "SELECT * FROM noticias WHERE IDSeccion = '".$seccion."' AND Habilitado = 1 ORDER BY OrdenHome ";
$res = mysql_query($query);
$total_registros = mysql_num_rows($res);
if($total_registros > 0)
{
for($i=0;$i<@mysql_num_rows($res);$i++)
{
$cuando = "hoy por la mañana";
$IDCatalogo = mysql_result($res,$i,"IDCatalogo" ;
$titolo_ita = mysql_result($res,$i,"titolo_ita" ;
$titolo_ing = mysql_result($res,$i,"titolo_ing" ;
$attore_ita = mysql_result($res,$i,"attore_ita" ;
$attore_ing = mysql_result($res,$i,"attore_ing" ;
$regia_ita = mysql_result($res,$i,"regia_ita" ;
$regia_ing = mysql_result($res,$i,"regia_ing" ;
$produzione_ita = mysql_result($res,$i,"produzione_ita" ;
$produzione_ing = mysql_result($res,$i,"produzione_ing" ;
$durata_ita = mysql_result($res,$i,"durata_ita" ;
$durata_ing = mysql_result($res,$i,"durata_ing" ;
$genere_ita = mysql_result($res,$i,"genere_ita" ;
$genere_ing = mysql_result($res,$i,"genere_ing" ;
$imagen = mysql_result($res,$i,"imagen" ;
?>
y el que inserte para el paginador:
<?
include('paginador.php');
$paging =& new Paging('SELECT * FROM catalogo');
$paging->set_perPage(10);
// te muestra X registros por pagina
// si no lo llamas el default es 10
$paging->set_strNext('>>');
$paging->set_strPrev('<<');
// Cual sera el str del boton siguiente y anterior?
// los defaults son >> <<
// puede ser incluso una imagen (html : <img src="...">
$paging->set_varName('page');
// pudes cambiarle el nombre a la variable GET
// sease usuarios.php?page=1
// el default es page
$res = $paging->getResult();
$nav = $paging->getMenu();
while($row = mysql_fetch_array($res))
{
echo "<b>$row[id_user]</b>:$row[userName] <br/>\n";
}
echo $nav;
?>