Tengo un formulario que tiene dos cajas texto son dos valores para realizar una consulta de cierto numero de registro a cierto numero por lo tanto esas dos cajas de texto tiene dos valores que mando por GET a otra pagina php
En la pagina PHP que realiza la consulta si me los en lista de 10 registros y despues el enlace alos siguientes registros pero se pierden las variables de las cajas de texto que puedo hacer este es mi codigo
Código PHP :
<?php
session_start();
$_SESSION['valor1']=$_GET['valor1'];
$_SESSION['valor2']=$_GET['valor2'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>..::RESULTADO_G::..o</title>
</head>
<body>
<center><h1><font color="#000033"> RESULTADO </font></h1></center>
<hr />
<?php
$conexion=mysql_connect("localhost","","");
mysql_select_db("registros",$conexion) or die ("ERROR DE BASE");
$limit=10;
$pag = (int) $_GET["pag"];
if ($pag < 1)
{
$pag = 1;
}
$offset = ($pag-1) * $limit;
$sql = "SELECT SQL_CALC_FOUND_ROWS id, nombre, apellido,edad,correo,estado FROM altas LIMIT $offset, $limit";
$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"];
$valor1=$_SESSION['valor1'];
$valor2=$_SESSION['valor2'];
$sql=mysql_query("SELECT id,nombre,apellido,edad,correo,estado FROM altas
WHERE id >=$valor1 AND id <=$valor2")
or die ("Error".mysql_error());
echo "<br />";
echo "<table border=\"1\" align=\"center\" width=\"80%\">";
echo "<tr>";
echo "<td width=\"20%\" heigth=\"15\"><center> REGISTRO </center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center> NOMBRE </center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center> APELLIDOS </center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center> EDAD </center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center> CORREO </center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center> ESTADO </center></td>";
echo "</tr>";
while ($reg=mysql_fetch_assoc($rs))
{
echo "<tr>";
echo "<td width=\"20%\" heigth=\"15\"><center>".$reg['id']."</center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center>" .$reg['nombre']."</center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center>" .$reg['apellido']."</center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center>".$reg['edad']."</center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center>".$reg['correo']."</center></td>";
echo "<td width=\"20%\" heigth=\"15\"><center>" .$reg['estado']."</center></td>";
echo "</tr>";
}
?>
<?php ?>
</td>
<td>
<?php ?>
</td>
</tr>
<?php
?>
</tbody>
<tfoot>
<tr>
<td colspan="2">
<?php
$totalPag = ceil($total/$limit);
$links = array();
for( $i=1; $i<=$totalPag ; $i++)
{
$links[] = "<a href=\"?pag=$i?valor1=$valor1&valor2$valor2\">$i</a>";
}
echo implode(" - ", $links);
mysql_close($conexion);
?>
</body>
</html>
