Código PHP:
<?
if (!isset($_server["PHP_SELF"]))
{
$_GET = $HTTP_GET_VARS;
$_POST = $HTTP_POST_VARS;
$_SESSION = $HTTP_SESSION_VARS;
}
$sexo = $_GET['sexo'];
//conexionBBDD
mysql_select_db($database, $connection);
$currentPage = $_SERVER["PHP_SELF"];
$registros = 3;
if (!$pagina) {
$inicio = 0;
$pagina = 1;
}
else {
$inicio = ($pagina - 1) * $registros;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Noticias</title>
<style>
body { font-family: arial; font-size:12px}
</style>
</head>
<body>
<?
$resultados = mysql_query("SELECT Id FROM Modelos WHERE Sexo = '$sexo' and Habilitado = 'SI'");
$total_registros = mysql_num_rows($resultados);
$resultados = mysql_query("SELECT * FROM Modelos WHERE Sexo = '$sexo' and Habilitado = 'SI' ORDER BY Id ASC LIMIT $inicio, $registros");
$total_paginas = ceil($total_registros / $registros);
if($total_registros) {
while($row=mysql_fetch_array($resultados)) {
?>
<b><?php echo $row['ID']; ?></b><br>
<font color='#666666'><?php echo $row['Nombre']; ?></font><br><br><br>
<?
}
} else {
echo "No se encontraron Modelos";
}
mysql_free_result($resultados);
if($total_registros) {
echo "<center>";
if(($_GET["pagina"] - 1) > 0) {
echo "<a href='$currentPage?pagina=".($_GET["pagina"]-1)."&sexo=$sexo'>Anterior</a> ";
}
for ($i=1; $i<=$total_paginas; $i++){
if ($_GET["pagina"] == $i)
echo "<b>".$_GET["pagina"]."</b> ";
else
echo "<a href='$currentPage?pagina=$i&sexo=$sexo'>$i</a> ";
}
if(($_GET["pagina"] + 1)<=$total_paginas) {
echo " <a href='$currentPage?pagina=".($_GET["pagina"]+1)."&sexo=$sexo'>Siguiente</a>";
}
echo "</center>";
}
?>
</body>
</html>