Ver Mensaje Individual
  #9 (permalink)  
Antiguo 12/07/2012, 02:27
kfh1992
 
Fecha de Ingreso: diciembre-2011
Mensajes: 414
Antigüedad: 12 años, 4 meses
Puntos: 1
Respuesta: Paginación PHP

Lo he conseguido ...una parte pero almenos algo es algo

Entonces como podria hacer para que en la pagina 1 salieran solo 2 articulos en la otra otros dos y asi sucesivamente
Cita:
<?php
// maximo por pagina
$limit = 10;
@$pag = 0;
// pagina pedida
@$pag = $_GET["pag"];
if ($pag < 1)
{
@ $pag = 1;
}
$offset = (@$pag-1) * $limit;


$sql = "SELECT * FROM articulos";
$sqlTotal = "SELECT FOUND_ROWS() as total";

$rs = mysql_query($sql);
$rsTotal = mysql_query($sqlTotal);

$rowTotal = mysql_fetch_assoc($rsTotal);
// Total de registros sin limit
$total = $rowTotal["total"];

?>
<style type="text/css">
<!--
.Estilo3 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; }
.Estilo6 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
.Estilo4 {font-size: 12px;
font-weight: bold;
}
.Estilo7 {font-size: 12px}
.Estilo14 {font-family: "Times New Roman", Times, serif; font-size: 14px; font-weight: bold; color: #FFFFFF; }
a:link {
color: #0000FF;
text-decoration: none;
}
a:visited {
color: #0000FF;
text-decoration: none;
}
a:hover {
color: #0000FF;
text-decoration: none;
}
a:active {
color: #0000FF;
text-decoration: none;
}
-->
</style>



<table width="703" border="0" align="center">
<tr>
<td width="169"><img src="http://www.forosdelweb.com/f18/Imagenes/rbv.png" width="169" height="62" /></td>
<td width="80"><strong><img src="http://www.forosdelweb.com/f18/Imagenes/logome.jpg" width="79" height="43" /></strong></td>
<td width="143"><span class="Estilo4">Ministerio del Poder Popular para la Educaci&oacute;n</span></td>
<td width="72"><img src="http://www.forosdelweb.com/f18/Imagenes/logoliceo.jpg" width="72" height="50" /></td>
<td width="217"><span class="Estilo7">LICEO BOLIVARIANO<br />
<strong>&ldquo;Rafael &Aacute;ngel Rond&oacute;n M&aacute;rquez&rdquo;</strong></span></td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
</table>
<p align="center" class="Estilo6">Listado de Alumnos por P&aacute;ginas </p>
<table width="683" border="1" align="center" bordercolor="#000" bgcolor="#FFFFFF">
<thead>
<tr>
<td width="59" bgcolor="#14285f"><div align="center"><span class="Estilo14">C&eacute;dula</span></div></td>
<td width="103" bgcolor="#14285f"><div align="center"><span class="Estilo14">Nombres</span></div></td>
<td width="130" bgcolor="#14285f"><div align="center"><span class="Estilo14">Apellidos</span></div></td>
</tr>
</thead>
<tbody>
<?php
while ($row = mysql_fetch_assoc($rs))
{
$Ced_alumno = $row["texto"];
$Nom_alumno = $row["titulo"];
$Ape_alumno = $row["alias"];
?>
<tr>
<td><span class="Estilo3"><?php echo $Ced_alumno; ?></span></td>
<td><span class="Estilo3"><?php echo $Nom_alumno; ?></span></td>
<td><span class="Estilo3"><?php echo $Ape_alumno; ?></span></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="6" bgcolor="#FFFFFF"><div align="center"><span class="Estilo3"><strong>P&aacute;gina:</strong>
<?php
$totalPag = ceil($total/$limit);
$links = array();
for( $i=1; $i<=$totalPag ; $i++)
{
$links[] = "<a href=\"?pag=$i\">$i</a>";
}
echo implode(" - ", $links);
?>
</span><span></span><span></span></div></td>
</tr>
</tfoot>
</table>
<p align="center"><a href="index.php">Vo
lver</a></p>