Hola, disculpas por volver a reflotar el tema, pero la cuestion es que ayer me olvidé de probar cuando iba hacia atrás el buscador. hacia adelante no hay problemas, sigue respetando los filtros pero hacia atras, vuelve a mostrarme todos los usuarios.
Dejo el código que tengo:
<?php
include('header.inc');
$id=$_SESSION["id"];
$usuario=$_SESSION["usuario"];
$pag=$_GET['pag'];
include_once ("connect.php");
$sexo = (!empty($_POST["sexo"]) ?
" sexo='".trim($_POST["sexo"])."'" : "");
$interestin = (!empty($_POST["interestin"]) ?
" AND interestin='".trim($_POST["interestin"])."'" : " interestin='".trim($_POST["interestin"])."'") : "");
$pais = (!empty($_POST["pais"]) ?
" AND pais='".trim($_POST["pais"])."'" : " pais='".trim($_POST["pais"])."'") : "");
$estadocivil= (!empty($_POST["estadocivil"]) ?
" AND estadocivil='".trim($_POST["estadocivil"])."'" : " estadocivil='".trim($_POST["estadocivil"])."'") : "");
? " WHERE "
: "");
if (!isset($pag)) $pag = 1; // Por defecto, pagina 1 $tampag = 5;
$reg1 = ($pag-1) * $tampag;
function paginar($actual, $total, $por_pagina, $enlace) {
$total_paginas = ceil($total/$por_pagina); $anterior = $actual - 1;
$posterior = $actual + 1;
if ($actual>1)
$texto = "<a href=\"$enlace$anterior\">«</a> ";
else
$texto = "<b>«</b> ";
for ($i=1; $i<$actual; $i++)
$texto .= "<a href=\"$enlace$i\">$i</a> ";
$texto .= "<b>$actual</b> ";
for ($i=$actual+1; $i<=$total_paginas; $i++)
$texto .= "<a href=\"$enlace$i\">$i</a> ";
if ($actual<$total_paginas)
$texto .= "<a href=\"$enlace$posterior\">»</a>";
else
$texto .= "<b>»</b>";
return $texto;
}
$s = "SELECT * FROM members "
. $where
. $sexo
. $interestin
. $pais
. $estadocivil
." LIMIT $reg1, $tampag";
?>
Para mostrar la paginacion:
<?php echo paginar($pag, $total, $tampag, "mostrar_resultados.php?pag="); ?>