Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/08/2011, 10:28
Pherenick
 
Fecha de Ingreso: octubre-2003
Mensajes: 12
Antigüedad: 20 años, 6 meses
Puntos: 1
Respuesta: Paginación - Pasar página sin perder los criterios de búsqueda

Yo lo tengo asi y me funciona bien:

Código:
   $coneccion=mysql_connect("localhost", "admin", "1234") or die(mysql_error());
			
			if (!(isset($pagenum))) 
			 { 
			 $pagenum = 1; 
			 } 

   mysql_select_db("prueba", $coneccion) or die(mysql_error());
   mysql_query("SET NAMES 'utf8'");
	
	$consulta=mysql_query("SELECT * FROM maquinas");

  
         $rows = mysql_num_rows($consulta);   //saber cuantas registros
	 $page_rows = 6;  //nuemro registros por pag
	 $last = ceil($rows/$page_rows);   // ultima pag

	 if ($pagenum < 1) 
	 { 
	 $pagenum = 1; 	    } 																		//colocacion nume pag
	 elseif ($pagenum > $last) 
	 { 
	 $pagenum = $last; 
	
	 } 
	 $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;    //maximo posible
	 
	 $data_p = mysql_query("SELECT * FROM maquinas  $max") or die(mysql_error()); 
   mysql_close($coneccion);

   
   
 while($registro=mysql_fetch_row($data_p))  	  {	

  echo  "<tr>
   			<td class='td'> ".$registro[0]." </td>
			<td class='td'> ".$registro[1]." </td>
			<td class='td'> ".$registro[2]." </td>
	
		 </tr> "; 
   }
  ?>	 
 
</table> 
<br/>
<?
 echo "<div class='paginacion' align='center'> ";
  if ($pagenum == 1) 
 {
 } 
 else 
 {
 echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <img border=0 title='ir al primero' src='images/icons/pagination_1_first.png'></a> ";
 echo " ";
 $previous = $pagenum-1;
 echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'><img  border=0 title='anterior' src='images/icons/pagination_1_previous.png'></a> ";
 } 
 //espaciado
 echo "Página  $pagenum  de  $last  ";
 if ($pagenum == $last) 
 {
 } 
 else {
 $next = $pagenum+1;
 echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'><img border=0 title='siguiente' src='images/icons/pagination_1_next.png'></a> ";
 echo " ";
 echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'><img border=0 title='ir al último' src='images/icons/pagination_1_last.png'></a> ";
 } 
 echo "</div>";
suerte y saludos.