Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/11/2007, 22:44
Rome
 
Fecha de Ingreso: octubre-2007
Ubicación: Buenos Aires
Mensajes: 9
Antigüedad: 16 años, 6 meses
Puntos: 0
Re: LIMIT ayuda !!

ESte es un ejemplo de paginacion....

tienes que cambiar los queries por los tuyos y los datos de conexion a la base de datos.

Espero que te sirva :

Código PHP:
<?php
    
@mysql_connect($localhost$user$password) or die("ERROR--CAN'T CONNECT TO SERVER");
    @
mysql_select_db($database) or die("ERROR--CAN'T CONNECT TO DB");
    
$limit          25;
    
$query_count    "SELECT count(*) FROM table";
    
$result_count   mysql_query($query_count);
    
$totalrows      mysql_num_rows($result_count);
    if(empty(
$page)){
        
$page 1;
    }
    
$limitvalue $page $limit - ($limit);
    
$query  "SELECT * FROM table LIMIT $limitvalue, $limit";
    
$result mysql_query($query) or die("Error: " mysql_error());
    if(
mysql_num_rows($result) == 0){
        echo(
"Nothing to Display!");
    }
    
$bgcolor "#E0E0E0"// light gray
    
echo("<table>");
    while(
$row mysql_fetch_array($result)){
        if (
$bgcolor == "#E0E0E0"){
            
$bgcolor "#FFFFFF";
        }else{
            
$bgcolor "#E0E0E0";
        }
    echo(
"<tr bgcolor=".$bgcolor.">n<td>");
    echo(
$row["users"]);
    echo(
"</td>n<td>");
    echo(
$row["usersID"]);
    echo(
"</td>n</tr>");
    }
    echo(
"</table>");
    if(
$page != 1){
        
$pageprev $page--;
        echo(
"<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> ");
    }else{
        echo(
"PREV".$limit." ");
    }
    
$numofpages $totalrows $limit;
    for(
$i 1$i <= $numofpages$i++){
        if(
$i == $page){
            echo(
$i." ");
        }else{
            echo(
"<a href=\"$PHP_SELF?page=$i\">$i</a> ");
        }
    }
    if((
$totalrows $limit) != 0){
        if(
$i == $page){
            echo(
$i." ");
        }else{
            echo(
"<a href=\"$PHP_SELF?page=$i\">$i</a> ");
        }
    }
    if((
$totalrows - ($limit $page))> 0){
        
$pagenext $page++;
        echo(
"<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>");
    }else{
        echo(
"NEXT".$limit);
    }
    
mysql_free_result($result);
?>