RE: [PHP-ES] Re: Siguiente Atras - Codigo
| From: | Alberto Ferrer | Date: | Wed, 19 Jun 2002 02:10:10 +0000 |
| Subject: | RE: [PHP-ES] Re: Siguiente Atras - Codigo | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-24021@lists.php.net to get a copy of this message | ||
<?
Este es un ejemplito de Como hacer el siguiente y atras, aca arriba
haces un SELECT * from tabla where condicion.
Si haces algo como :
for ($i = 0; $i < $sql->rows; $i++) {
$sql->Fetch($i);
Calculas la cantidad de registros.
Debajo de este codigo agregas esto a tu query:
$RL,$MaxRow.
Este es un ejemplo: SELECT * FROM bh_art where aid order by aid DESC
LIMIT $RL,$MaxRow
Esto generaria algo como <<< [1] [2] [3] >>> ( Solo si tenes estos
registros, si no hay nada aparece nada )
$MaxRow = 2; /* Cantidad de Registros por pagina */
if (!isset($CR))
{
$CR=$sql->rows;
$RL=0;
}
$Barrahome=intval($CR/$MaxRow);
if ($Barrahome < ($CR/$MaxRow)){ $Barrahome++;}
echo "<CENTER>";
if ($RL > 0) {
$y=$RL-$MaxRow;
echo "[<a href=\"/ index.php?CR=$CR&RL=$y \"><<</a>]
";
}
for ($i = 1; $i <= $Barrahome; $i++)
{ $y=($i*$MaxRow)-$MaxRow;
if ($y==$RL){echo "<B>";}
echo "[<a href=\"/ index.php?CR=$CR&RL=$y \">$i</a>] ";
if ($y==$RL){echo "</B>";}
}
if ($RL < ($CR-$MaxRow)) {
$y=$RL+$MaxRow;
echo "[<a href=\"/ index.php?CR=$CR&RL=$y \">>></a>]
";
}
echo "</CENTER>";
}
?>
Alberto Ferrer
albertof@deltasoft.com.ar
http://www.deltasoft.com.ar
Happy Code Today!