 
			
				10/09/2013, 12:07
			
			
			     |  
      |    |    |    Fecha de Ingreso: junio-2013  Ubicación: santiago  
						Mensajes: 34
					  Antigüedad: 12 años, 4 meses Puntos: 0     |        |  
  |      Respuesta: Paginación con filtros casi acabada, pequeño fallito q me atasca        hola, sabes yo tengo el mismo problema, pero hay un buscador de por medio, en vez del filtro, y me pasa lo mismo al buscar me muestran 3 paginas de las 10 en total, y al ir a la segunda o tercera esta se vuelve a la principal con las 10 paginas nuevamente.  
pero mi codigo es muy distinto al tuyo..   Cita:     
<html>  
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> 
<link href="style.css" rel="stylesheet" type="text/css" /> 
<link href="paginacion.css" type="text/css" rel="stylesheet"> 
</head>       
<body> 
<form width="650" method="POST" action=""  name="formulario" id="formulario">  
<table> 
<tr> 
<td width="250px;"><strong>Nombres:</strong>  <input type="text" name="busca" id="busca" size="20"></td> 
<td width="250px;"><strong>Area:</strong>   
<select width="150" name="busca1"> 
<option value="">Seleccione Area</option> 
  <option value="Unidad Minería">Unidad Minera</option> 
  <option value="Casa Matriz">Casa Matriz</option> 
  <option value="Unidad Teniente">Unidad Teniente</option> 
  <option value="Unidad Obras Civiles">Unidad Obras Civiles</option> 
  </select> 
</td> 
<td width="250px;"><strong>Cargo:</strong>  <input type="text" name="busca2" id="busca2" size="20"></td> 
 <td><input class="enter_buscar" type="submit" value="Buscar"></td> 
</tr>   
</form>    
</br> 
<?php 
include("db.php");   
$conn=get_db_conn(); 
  mysql_query("set names utf8");   
if(isset($_GET['page'])) 
{ 
    $page= $_GET['page']; 
} 
else 
{   
    $page=1; 
} 
?> 
<br> 
<?php 
$busca=""; 
$busca1=""; 
$busca2="";   
//variable vacia para que se inicalize 
$busca=trim($_POST['busca']); 
$busca1=trim($_POST['busca1']); 
$busca2=trim($_POST['busca2']);   
//busca despues del espacio vacio 
$busca=str_replace(" "," ",$busca); 
$busca1=str_replace(" "," ",$busca1); 
$busca2=str_replace(" "," ",$busca2);   
$consulta="SELECT area,  
				   nombre,  
				   cargo,  
				   ubicacion,  
				   telefono,  
				   fecha_nacimiento,  
				   foto  FROM directorio_telefonico where nombre like  '%".$busca."%'and area like '%".$busca1."%' and cargo like '%".$busca2."%'"; 
$datos=mysql_query($consulta,$conn);     
$num_rows=mysql_num_rows($datos);     
$rows_per_page= 3;     
$lastpage= ceil($num_rows / $rows_per_page);   
$page=(int)$page;   
if($page > $lastpage) 
{ 
    $page= $lastpage; 
}   
if($page < 1) 
{ 
    $page=1; 
}     
$limit= 'LIMIT '. ($page -1) * $rows_per_page . ',' .$rows_per_page;     
$consulta .=" $limit"; 
$directorioTelefonico=mysql_query($consulta,$conn)  ;   
if(!$directorioTelefonico) 
{   
        die('Invalid query: ' . mysql_error()); 
} 
else 
{   
      ?>        
    <?php while($row = mysql_fetch_assoc($directorioTelefonico)) 
          {  ?>     
     <tr class="par"> 
       <td>Area:</td> 
       <td><?php echo $row['area'] ?></td> 
     </tr>   
	 <tr class="par"> 
      <td>Nombre:</td> 
      <td><?php echo $row['nombre'] ?></td> 
     </tr>   
     <tr class="par"> 
     <td>Cargo:</td> 
     <td><?php echo $row['cargo']  ?></td> 
     </tr>   
     <tr class="par"> 
     <td>Ubicacion:</td> 
     <td><?php echo $row['ubicacion'] ?></td> 
     </tr>   
     <tr class="par"> 
	  <td>Telefono</td> 
	  <td><?php echo $row["telefono"]; ?></td> 
     </tr>   
	 <tr class="par"> 
	  <td>Fecha Nacimiento</td> 
	  <td><?php echo date("d/m/y", strtotime ($row["fecha_nacimiento"])); ?></td> 
	 </tr>   
	 <tr class="par"> 
	  <td>Foto</td> 
      <td> <img src="./fotos-prueba-directorio/<?php echo $row["foto"]; ?>" width="120" height="140">  </td> 
     </tr>		     
   <?php  } ?>       
    <?php   
	//muestra la paginacion siempre y cuando haya mas de una pagina     
    if($num_rows != 5) 
    { 
       $nextpage= $page +1; 
       $prevpage= $page -1;   
       ?>   
	   <ul id="pagination-digg">   
	   <?php   
           if ($page == 0)  
           { 
            ?> 
              <li class="previous-off">« Anterior</li> 
              <li class="active">1</li>  
         <?php 
              for($i= $page+1; $i<= $lastpage ; $i++) 
              {?> 
                <li><a href="busca-nombre2.php?page=<?php echo $i;?>"><?php echo $i;?></a></li> 
        <?php }   
           //Y SI LA ULTIMA PÁGINA ES MAYOR QUE LA ACTUAL MUESTRO EL BOTON NEXT O LO DESHABILITO 
            if($lastpage >$page ) 
            {?>       
                <li class="next"><a href="busca-nombre2.php?page=<?php echo $nextpage;?>" >Siguiente »</a></li> 
			<?php 
            } 
            else 
            {?> 
                <li class="next-off">Next »</li> 
        <?php 
            } 
        }  
        else 
        {   
            //EN CAMBIO SI NO ESTAMOS EN LA PÁGINA UNO HABILITO EL BOTON DE PREVIUS Y MUESTRO LAS DEMÁS 
        ?> 
            <li class="previous"><a href="busca-nombre2.php?page=<?php echo $prevpage;?>">« Anterior</a></li> 
			<?php 
             for($i= 1; $i<= $lastpage ; $i++) 
             {   
                if($page == $i) 
                { 
            ?>       <li class="active"><?php echo $i;?></li> 
			<?php 
                } 
                else 
                { 
            ?>       <li><a href="busca-nombre2.php?page=<?php echo $i;?>" ><?php echo $i;?></a></li> 
			<?php 
                } 
            }   
            if($lastpage >$page ) 
            {   ?>    
                <li class="next"><a href="busca-nombre2.php?page=<?php echo $nextpage;?>">Siguiente »</a></li> 
				<?php   
            } 
            else 
            { 
             ?>       
			 <li class="next-off">Siguiente »</li>   
			 <?php 
            } 
        }      
    ?> 
	</ul> 
	</div> 
	<?php   
    }  
}   
?>  
</table> 
<body> 
</html>                |