Foros del Web » Programando para Internet » PHP »

error al paginar php y sql server

Estas en el tema de error al paginar php y sql server en el foro de PHP en Foros del Web. al paginar me muestra los enlaces pero no los datos de la consulta no se que estare haciendo mal. Este es el codigo que utilizo: ...
  #1 (permalink)  
Antiguo 29/07/2006, 16:30
 
Fecha de Ingreso: abril-2006
Mensajes: 100
Antigüedad: 18 años
Puntos: 0
error al paginar php y sql server

al paginar me muestra los enlaces pero no los datos de la consulta no se que estare haciendo mal.


Este es el codigo que utilizo:

<?php
require_once("conexion.php");

//COSTANTES PARA EL DESPLIEGUE DE RESULTADOS
define("LIMITE", 2);
define("TAM_VENTANA", 10);


//CALCULO EL NUMERO DE REGISTROS
$total = 0;

//PROCEDIMIENTO ALMACENADO QUE DETERMINA EL NUMERO DE REGISTROS
$sqli3 = "SELECT count(ProblemaID) as cant from Problema";
$con3 = odbc_exec($enl, $sqli3);
$reg3 = odbc_fetch_array($con3);


$numero_de_registros = $reg3['cant'];
echo $numero_de_registros;
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Paginación PHP - SQL Server</title>
<style type="text/css">
<!--
.titulo{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
}
.texto
{font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }

-->
</style>
</head>

<body>
<p class="titulo">Paginaci&oacute;n de Resultados PHP - SQL Server 2000 </p>
<span class="Estilo2">Número total de registros: <?php echo $numero_de_registros ?></span><br>
<span class="Estilo2">Número de registros por página: <?php echo LIMITE ?></span><br><br>

<table width="50%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td bgcolor="#CCCCCC">ID RADIO</td>
<td bgcolor="#CCCCCC">NOMBRE RADIO</td>
</tr>
<?php

$pagina = $_GET['pagina'];
$limite = LIMITE;
if( isset( $pagina ) ) {
}
else {
$pagina = 1;
}

$maximo = ($pagina * $limite);
$minimo = $maximo - ($limite - 1);
$sqli = "SELECT ProblemaID, Titulo from Problema WHERE ProblemaID BETWEEN $minimo AND $maximo";
$con = odbc_exec($enl, $sqli);
$reg = odbc_fetch_array($con);

$num_paginas_float = $numero_de_registros / $limite; //número total de páginas a mostrar (float)
$valor_redondeado = ceil($num_paginas_float); //número total de páginas a mostrar (entero)
$inferior = $pagina - ( ceil( TAM_VENTANA / 2 ) );
$inicio_ventana = 1;
if( $valor_redondeado > TAM_VENTANA ) {
$inicio_ventana = ( $inferior < 1 ) ? 1 : $inferior + 1;
}
$fin_ventana = $inicio_ventana + ( TAM_VENTANA - 1 );
if( ( $fin_ventana > $valor_redondeado ) && ( $valor_redondeado > TAM_VENTANA ) ) {
$inicio_ventana = $valor_redondeado - ( TAM_VENTANA - 1 );
}
$contador = $inicio_ventana;

// if( $reg > 0 ) {

while($reg) {
?>
<tr>
<td bgcolor="#FFFFF0"><?php echo $reg['ProblemaID']; ?></td>
<td bgcolor="#FFFFF0"><?php echo $reg['Titulo']; ?></td>
</tr>
<?php
$reg = odbc_fetch_array($con);
}
//}
?>
</table>
<br>
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" align="left">
<?php
if( $pagina > 1 ) {
$numero_pagina = $pagina - 1;
?>
<a href="pag.php?pagina=<?php echo $numero_pagina ?>">&laquo;&nbsp;Anterior</a>
<?php
}
else{
?>
&nbsp;
<?php
}
?>
</td>
<td width="30%" align="center">
<?php
if( ( $numero_de_registros > 0 ) && ( $valor_redondeado > 1 ) ) {
$nuevo_inicio = ($inicio_ventana * $limite) - $limite;
while ( ( $contador <= $valor_redondeado ) && ( $contador <= $fin_ventana) ) {
$string_contador = "";
if( $contador > $inicio_ventana ) {
$nuevo_inicio += $limite;
}
if( $pagina == $contador ) {
$string_contador = "<b>$contador</b>";
}
else {
$string_contador = "$contador";
}
if( ( $pagina < $contador ) || ( $pagina > $contador ) ) {
?>
&nbsp;<a href="pag.php?pagina=<?php echo $contador ?>"><?php echo $string_contador ?></a>&nbsp;<?php
}
else {
echo "&nbsp;" . $string_contador . "&nbsp;";
}
$contador++;
}
}
?>
</td>
<td width="10%" align="right">
<?php
if( $pagina < $valor_redondeado ) {
$numero_pagina = $pagina + 1;
?>
<a href="pag.php?pagina=<?php echo $numero_pagina ?>">Siguiente&nbsp;&raquo;</a><?php
}
else{
?>
&nbsp;
<?php
}
?>
</td>
</tr>
</table>

</body>
</html>
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 15:46.