Por ej. asi me lo muestra:
< Anterior 0 1 2 3 Siguiente >
Este es el script
Código PHP:
if (isset($_SESSION['s_username'])) {
include("config_usuarios.php");
$sesion = $_SESSION['s_username'];
//Configuracion
$cantidad = 9;
//Calculo
if (!isset($pg)) { $pg = 0; }
$inicial = $pg * $cantidad;
//Consulta general
$sql_gen = "SELECT * FROM imagenes WHERE username = '$sesion'";
$cons_gen = mysql_db_query($dbname,$sql_gen) or die (mysql_error());
$total_registros = mysql_num_rows($cons_gen);
$cant_paginas = intval($total_registros / $cantidad);
//Consulta acotada
$sql_acot= "SELECT * FROM imagenes WHERE username = '$sesion' ORDER BY id DESC LIMIT $inicial,$cantidad";
$cons_acot = mysql_db_query($dbname,$sql_acot) or die (mysql_error());
?>
<table align="center" width="1" border="0" cellspacing="50" cellpadding="0"><tr>
<?
//Impresion del listado
while ($array = mysql_fetch_array($cons_acot))
{
if ($contador == 3) {
echo "</tr><tr>";
$contador = 0;
}
$contador++;
echo '<td width="100"><a href="'.$array[imagen].'" target="_blank"><img width="150" height="150" src="'.$array[imagen].'"></a></td>';
}
}
echo "</tr></table><br><br>";
//Impresion - Creacion de enlaces de paginacion
echo "<center><p>";
if ($pg <>0)
{
$guia = $pg - 1;
echo "<font><a href='album.php?pg=".$guia."'>« Anterior</a> </font>";
}
else {
echo " ";
}
for ($i = 0; $i<($cant_paginas + 1); $i++) {
if ($i == $pg) {
echo "<font><b> $i </b></font>";
}
else {
echo "<font><a href='album.php?pg=".$i."'>".$i."</a> </font>";
}
}
if ($pg < $cant_paginas) {
$guia= $pg + 1;
echo "<font><a href='album.php?pg=".$guia."'>Siguiente »</a></font>";
}
else {
echo " ";
}
echo "</p></center>";
echo "<br><br><a href='index.php'>Volver</a>";