Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/07/2010, 14:40
condesitadeirun
 
Fecha de Ingreso: noviembre-2007
Ubicación: Irun
Mensajes: 79
Antigüedad: 16 años, 6 meses
Puntos: 0
Pregunta Variables GET en MySQL

Buenas,
Sigo trabajando en el mismo proyecto que el mensaje anterior y creo que el problema esta en que la variable no se envia correctamente o no la mantiene...

Cita:
<?php
include("conexion.php");
$limit = 5;
// pagina pedida
$pag = (int) $_GET["pag"];
$pueblo=$_GET['localidad'];


if ($pag < 1)
{
$pag = 1;
}
$offset = ($pag-1) * $limit;
$sql = "SELECT SQL_CALC_FOUND_ROWS ref,tipo FROM ".$_GET['localidad']." LIMIT $offset, $limit";
$sqlTotal = "SELECT FOUND_ROWS() as total";
echo $sql;
$rs = mysql_query($sql);
$rsTotal = mysql_query($sqlTotal);

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

?>


<table border="1" bordercolor="#000">
<thead>
<tr>
<td>Id</td>

</tr>
</thead>
<tbody>

<?php
while ($row = mysql_fetch_assoc($rs))
{
$ref = $row["ref"];
$tipo=$row["tipo"];

?>

<tr>
<td>
<?php echo $ref; ?>
</td>
<td>
<?php echo $tipo; ?>
</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&pueblo=".$_GET['localidad']." \">$i</a>";
}
echo implode(" - ", $links);
?>