Foros del Web » Programando para Internet » PHP »

paginador sencillo boton anterior y sigueinte

Estas en el tema de paginador sencillo boton anterior y sigueinte en el foro de PHP en Foros del Web. Buenas compañeros; Estoy tratando de hacer un paginador sencillo de noticias, con botón de anterior y siguiente. Pero me está resultando dificicil. Quiero que me ...
  #1 (permalink)  
Antiguo 12/07/2006, 04:42
Avatar de susaninhax  
Fecha de Ingreso: noviembre-2004
Mensajes: 358
Antigüedad: 19 años, 4 meses
Puntos: 3
Pregunta paginador sencillo boton anterior y sigueinte

Buenas compañeros;

Estoy tratando de hacer un paginador sencillo de noticias, con botón de anterior y siguiente. Pero me está resultando dificicil.
Quiero que me muestre las noticias de 2 en 2, y lo único que se me ha ocurrido es esto pero no se ni como decirle que me muestre 2, ni como indicarselo en los botones de siguiente y anterior....
Tengo la cabeza hecha un lío....
Código PHP:
   <table bgcolor="#EFEFF1" align="center" cellspacing="0" cellpadding="0" border="0" width="256px">
<?php                       
$sql
="select id_noticia, titulo, frase
      from noticias
      where activo='si'
      order by  fotografia"

      
$result=mysql_query($sql,$link) or die(mysql_query());
$cont=0;                                
while(
$row=mysql_fetch_array($result)){
$id_noticia[$cont]=$row["id_noticia"];    
$titulo[$cont]=$row["titulo"];
$frase[$cont]=$row["frase"]
$cont++;
$conta_matriz=count($id_noticia);  ?>


    <tr>
        <td width="127px" valign="top"><img src="aquí la imagen>" galleryimg="no"></td>
        <td width="12px"><img src="../../images/shim.gif" galleryimg="no" WIDTH="1" HEIGHT="1"></td>
        <td width="111px" valign="top"><?php echo $titulo[$_GET["cont"]]; ?><br><span class="texto_gris_peque"><?php echo $frase[$_GET["cont"]]; ?> </span>         
          <br>
      </td>
        
    </tr><tr>
        <td colspan="3"><img src="../../images/shim.gif" height="18px"></td>
    </tr>
<? ?>
    </table>

    <table align="center" cellpadding="0" cellspacing="0" border="0" width="256px"><tr>
        <td valign="bottom" nowrap><img src="../../images/shim.gif" width="8px"><font class="texto3"></font> <?php if ($_GET["cont"]>'0') {?>
<a href="<? echo $_SERVER['PHP_SELF']; ?>?cont=<?php echo ($_GET["cont"]-1); ?>"><img src="../../images/anterior.gif" border="0" WIDTH="100" HEIGHT="16"></a></td>

        <td nowrap><img src="../../images/shim.gif" border="0" WIDTH="1" HEIGHT="1"></td>
<?php if($_GET["cont"]<($conta_matriz-1)) {?>
        <td valign="bottom" align="right" nowrap><a href="<? echo $_SERVER['PHP_SELF']; ?>?cont=<?php echo ($_GET["cont"]+1); ?>"><img src="../../images/siguiente.gif" border="0" WIDTH="100" HEIGHT="16"></a><img src="../../images/shim.gif" width="13px"></td>
<?php }elseif($_GET["cont"]== '0'){?>

        <td align="right" nowrap><img src="../../images/shim.gif" border="0" WIDTH="1" HEIGHT="1"><img src="../../images/shim.gif" width="13px"></td>
<?php ?>

    </tr></table>
Alguien me ayuda a hacer que esto funcione porfaaa!!!!!

Muchas gracias de antemano!!

Última edición por susaninhax; 12/07/2006 a las 04:51
  #2 (permalink)  
Antiguo 12/07/2006, 04:54
 
Fecha de Ingreso: junio-2006
Mensajes: 87
Antigüedad: 17 años, 9 meses
Puntos: 0
Usando MySQL utiliza LIMIT, con esto indicas el número de registros que necesitas obtener, y a partir de cual, por ejempolo quiero 2 registros a partir del número 10 (te mostraría el 11 y el 12)

En el FAQ hay un ejemplo
http://www.forosdelweb.com/showpost....&postcount=145

y si buscas en google paginar Php Mysql hay muchas páginas que te explican paso a paso como realizar la tarea.
  #3 (permalink)  
Antiguo 12/07/2006, 15:36
Avatar de rogertm
Mod->Cuba
 
Fecha de Ingreso: julio-2005
Ubicación: /home/Cuba/Habana/rogertm/
Mensajes: 2.922
Antigüedad: 18 años, 8 meses
Puntos: 638
hola susaninhax
creo que lo que quieres hacer lo puedes hacer con dreamweaver, tan sencillo como esto:
menu insert + application objects + recordset paging + recordset navigation nav.....

ve a ver si te sirve eso, espero que si, yo tambien tenia esa duda y lo descubri justo hoy, suarte bro.
RogerTM
  #4 (permalink)  
Antiguo 12/07/2006, 16:08
Avatar de jpinedo
Colaborador
 
Fecha de Ingreso: septiembre-2003
Ubicación: Lima, Perú
Mensajes: 3.120
Antigüedad: 20 años, 6 meses
Puntos: 41
Hola Susaninhax:
Puedes probar con Paginator. Tu código quedaría así:
Código PHP:
<table bgcolor="#EFEFF1" align="center" cellspacing="0" cellpadding="0" border="0" width="256px">
<?php                       
$_pagi_sql 
"select id_noticia, titulo, frase 
                from noticias 
                where activo='si' 
                order by  fotografia"

$_pagi_cuantos 2// 2 resultados por página.
$_pagi_nav_num_enlaces 3// Cuántos enlaces de páginas deberán aparecer.
$_pagi_nav_anterior '<img src="../../images/anterior.gif" border="0" width="100" height="16">';// img "anterior"
$_pagi_nav_siguiente '<img src="../../images/siguiente.gif" border="0" width="100" height="16">';// img "siguiente"
include("paginator.inc.php");

while(
$row=mysql_fetch_array($_pgi_result)){
    
$id_noticia $row['id_noticia'];
?>
    <tr>
        <td width="127px" valign="top"><img src="aquí la imagen>" galleryimg="no"></td>
        <td width="12px"><img src="../../images/shim.gif" galleryimg="no" WIDTH="1" HEIGHT="1"></td>
        <td width="111px" valign="top">
            <?php echo $row['titulo']; ?><br>
            <span class="texto_gris_peque"><?php echo $row['frase']; ?></span><br>
        </td>
    </tr>
    <tr>
        <td colspan="3"><img src="../../images/shim.gif" height="18px"></td>
    </tr>
<?php
}
?>
    </table>
<?php echo"<p>".$_pagi_navegacion."</p>"?>
Sólo tienes que descargar el script "paginator.inc.php".

Puedes jugar con la variable $_pagi_nav_num_enlaces para que se muestren más o menos enlaces.

Ojalá te sirva.

Saludos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:17.