Ver Mensaje Individual
  #5 (permalink)  
Antiguo 30/12/2009, 03:52
rastafinis
 
Fecha de Ingreso: mayo-2006
Mensajes: 86
Antigüedad: 18 años
Puntos: 0
Respuesta: ayuda con paginacion de consulta mysql

muchas gracias fue de gran ayuda

este es el code resultante aunque falta dar un toke de diseño pero funciona al 100%

Código:
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="25"><div id="moduloforos"><? echo $lang['titulomoduloforo'] ?></div></td>
                  </tr>
<?
$connection = mysql_connect ($lang['bd_host'],$lang['bd_usuario'],$lang['bd_password']);
if(!$connection) { die(mysql_error()); }
mysql_select_db($lang['bd_base']);
if(!@mysql_select_db($lang['bd_base'],$connection)) { die(mysql_error()); }
if ($cat == 0){$sql_text = "SELECT * FROM johwic_topicos WHERE foro_id <> '$cat' order by grupo_id desc limit $inicio,$fin"; }
else {$sql_text = "SELECT * FROM johwic_topicos WHERE foro_id = '$cat' order by grupo_id desc limit $inicio,$fin"; }
$cats=0;
if ($r = mysql_query($sql_text,$connection)){
while ($row = mysql_fetch_array($r)){
	

                 $cats ++; 

$resto = substr ($row['topico_titulo'], 0, 48 );

?>
                  <tr>
                    <td width="" align="left" valign="top" id="resultadosdb" onClick="MM_goToURL('parent','ficha.php?ndii=<? echo $row['topico_id'] ?>');return document.MM_returnValue"><div id="moduloforos2">
					
							<? $idforo = $row['foro_id']; 
							if($idforo == 1) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/flash.gif" width="20" height="20"><? } 
							if($idforo == 2) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/temas.gif" width="20" height="20"><? }
							if($idforo == 3) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/arte.gif" width="20" height="20"><? }
							if($idforo == 4) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/autos.gif" width="20" height="20"><? }
							if($idforo == 5) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/cel.png" width="20" height="20"><? }
							if($idforo == 6) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/Comic.gif" width="20" height="20"><? }
							if($idforo == 7) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/deportes.png" width="20" height="20"><? }
							if($idforo == 8) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/descargas.gif" width="20" height="20"><? }
							if($idforo == 9) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/tutoriales.gif" width="20" height="20"><? }
							if($idforo == 10) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/economia.gif" width="20" height="20"><? }
							if($idforo == 11) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/mujeres.png" width="20" height="20"><? }
							if($idforo == 12) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/humor.gif" width="20" height="20"><? }
							if($idforo == 13) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/imagenes.gif" width="20" height="20"><? }
							if($idforo == 14) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/informacion.png" width="20" height="20"><? }
							if($idforo == 15) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/juegos.png" width="20" height="20"><? }
							if($idforo == 16) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/link.gif" width="20" height="20"><? }
							if($idforo == 17) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/linux.gif" width="20" height="20"><? }
							if($idforo == 18) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/mac.gif" width="20" height="20"><? }
							if($idforo == 19) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/manga.png" width="20" height="20"><? }
							if($idforo == 20) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/mascota.gif" width="20" height="20"><? }
							if($idforo == 21) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/musica.jpg" width="20" height="20"><? }
							if($idforo == 22) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/noticias.png" width="20" height="20"><? }
							if($idforo == 23) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/offtopic.gif" width="20" height="20"><? }
							if($idforo == 24) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/patrocinados.jpg" width="20" height="20"><? }
							if($idforo == 25) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/recetas.gif" width="20" height="20"><? }
							if($idforo == 26) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/salud.png" width="20" height="20"><? }
							if($idforo == 27) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/sociales.png" width="20" height="20"><? }
							if($idforo == 28) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/j.png" width="20" height="20"><? }
							if($idforo == 29) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/turismo.gif" width="20" height="20"><? }
							if($idforo == 30) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/peliculas.gif" width="20" height="20"><? }
                            if($idforo == 31) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/video.png" width="20" height="20"><? }
							?>                      
							
							<? $idgrupo = $row['grupo_id']; 
							if($idgrupo == 0) { ?><? } 
							if($idgrupo == 1) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/registrate.png" width="20" height="20"><? }
							if($idgrupo == 2) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/j.png" width="20" height="20"><? }
							?> 
							
				<span id="forspan"><? echo $resto; ?>...</span></div></td>
                  </tr>
<?
                 }}
mysql_close($connection);
if($cats == 0) {
$cats = 0; }
?>
           <tr>
           <td align="center" bgcolor="#C1C1C1">  
		  <table width="200" border="1">
		    <tr>
		      <td><? if ($inicio==0) { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/humor.gif" width="20" height="20" /><? }
else
{
  $anterior=$inicio-$fin;
 ?><div id="ante" onclick="MM_goToURL('parent','?cat=<? echo $cat ?>&pag=<? echo $anterior ?>');return document.MM_returnValue" onMouseOver="MM_changeProp('ante','','color','#000','DIV');MM_changeProp('ante','','backgroundColor','#96C8E2','DIV');MM_changeProp('ante','','textDecoration','underline','DIV')" onMouseOut="MM_changeProp('ante','','textDecoration','none','DIV');MM_changeProp('ante','','color','#FFF','DIV');MM_changeProp('ante','','backgroundColor','#4FA0CC','DIV')"><? echo $lang['monbremenu2boton2'] ?></div> <? } ?> 
 			
            </td>
			<td><?
if ($cats==$fin)
{
  $proximo=$inicio+$fin;
  ?><div id="sigi" onclick="MM_goToURL('parent','?cat=<? echo $cat ?>&pag=<? echo $proximo ?>');return document.MM_returnValue" onMouseOver="MM_changeProp('sigi','','color','#000','DIV');MM_changeProp('sigi','','backgroundColor','#96C8E2','DIV');MM_changeProp('sigi','','textDecoration','underline','DIV')" onMouseOut="MM_changeProp('sigi','','textDecoration','none','DIV');MM_changeProp('sigi','','color','#FFF','DIV');MM_changeProp('sigi','','backgroundColor','#4FA0CC','DIV')"><? echo $lang['monbremenu2boton2'] ?></div> <?
}
else
  { ?><img src="http://www.forosdelweb.com/f18/imagenes/icopost/j.png" width="20" height="20" /><? } ?>
  			
            </td>
		      </tr>
		    </table>

             </td></tr>
                </table>

y antes del head


Código:
<? $cat = $_GET['cat']; 

if (isset($_REQUEST['pag']))
  $inicio=$_REQUEST['pag'];
else
  $inicio=0;
  $fin=20;
?>
lo demas es solo variables y otros includes que no tiene que ver mucho

espero a alguien que lo necesesite sea de ayuda

bye bye