·
miarroba.com

Paginacion PHP
  · Índice de subforos · PHP

Buscar · Tags · Tagboard · Usuarios · Fisgona · F.A.Q.

Autor Mensaje 
marianobrusmarianobrus
Usuario Novato
Usuario Novato


Mensajes: 2
Desde: 24/Nov/2007
Paginacion PHP

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&ntilde;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;
?>


24/Nov/2007 16:07 GMT+1 Perfil ·  Privado · Desconectado
Publicidad
· Índice de subforos · PHP

Temas similares Autor#VisitasÚltimo post
problemas con config.php uregistrar.php uentrar.php ulogin.php10/Jun/2004, 21:44
LA_BASE_MUSICALLA_BASE_MUSICAL
 8 1.18411/Jun/2004, 20:54
LA_BASE_MUSICALLA_BASE_MUSICAL Ir al último mensaje del tema
Paginacion (creo q es asi)18/May/2006, 22:42
bellacordbellacord
 3 71124/Nov/2007, 17:29
marianobrusmarianobrus Ir al último mensaje del tema
[PHP] Librería Gráfica GD con PHP20/May/2003, 18:56
Maska45Maska45
 6 2.04705/Jun/2006, 00:00
inigoruizinigoruiz Ir al último mensaje del tema
configurar php.ini para las sesiones php04/Oct/2004, 23:41
macho69macho69
 11 6.71130/Jun/2008, 20:57
NoSetup.orgNoSetup.org Ir al último mensaje del tema
Scripts Php completos (troyano con php indetectable e ind, administrador, chat en tiempo real etc..)12/Jun/2004, 17:22
neodelitoneodelito
 0 1.206No hay respuestas

Opciones:

Versión imprimible del tema
Subscríbete a este tema
Date de baja de este tema
Menear este tema en meneame.net
Ir al subforo:  

TU NO PUEDES Escribir nuevos temas en este foro
TU NO PUEDES Responder a los temas en este foro
TU NO PUEDES Editar tus propios mensajes en este foro
TU NO PUEDES Borrar tus propios mensajes en este foro

Todas las fechas y horas son GMT+1. Ahora son las 20:05
Miarroba Networks, S.L. Apartado de correos, 50, 39610 Astillero (CANTABRIA) - CIF B-39512736
Inscrita en el Registro Mercantil de Cantabria, tomo 743, folio 161, libro 0, hoja S-12428, Instripción 1ª