Buenas foro
Tengo un problema al hacer una paginación de una busqueda. Proceso la información en el mismo archivo, la paginación esta muy bien en la primer pagina pero al pasar a la siguiente pagina se pierden los datos alguien podria ayudarme.
Intente con una variable de session de tampoko me funciono
este es el archivo donde muestro todo:
Código PHP:
Ver original<?php
require_once '../clases/connection.class.php';
require_once '../clases/login.class.php';
require_once '../clases/utilidades.class.php';
require_once '../clases/reportes.class.php';
$connection=new Connection();
$login=new login($connection);
$utilidades=new utilidades($connection);
$reportes=new reportes($connection);
$login->seguridad();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Nuevo pedido</title>
<link href="../img/favicon.png" type="image/x-icon" rel="shortcut icon" />
<link rel="stylesheet" type="text/css" href="../styles/style.css" />
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/redmond/jquery-ui.css" >
<link type="text/css" rel="stylesheet" href="../styles/dhtmlgoodies_calendar.css?random=20051112" media="screen">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script src="../js/dhtmlgoodies_calendar.js?random=20060118"></script>
<script src="../js/funciones.js"></script>
<script src="../js/paginador_ajax.js"></script>
<?php include '../fancyboxDentro.html'; ?>
<script src="../js/abrirMensajes.js"></script>
</head>
<body>
<div id="contenedor">
<?php echo $utilidades->header(); ?> <?php if(!isset($_POST['search'])): ?> <section id="advanceSearch">
<h1>Búsqueda avanzada</h1><hr />
<form action="" method="POST">
<label>Desde: </label><input type="text" name="desde" readonly />
<input type="button" onclick="displayCalendar(document.forms[0].desde,'yyyy/mm/dd',this)"/>
<label>Hasta: </label> <input type="text" name="hasta" readonly />
<input type="button" onclick="displayCalendar(document.forms[0].hasta,'yyyy/mm/dd',this)"/>
<br />
<label>Cliente: </label> <input type="text" name="cliente" id="cliente" size="60" />
<br />
<label>Asociado: </label><select name="asociados">
<option selected="selected">.::Asociados::.</option>
<?php
if($asociados=$reportes->listarAsociados()):
foreach($asociados as $asociado): ?>
<option value="<?php echo $asociado->asociadoID; ?>"><?php echo $asociado->nombreAsociado; ?></option>
<?php
endforeach;
endif; ?>
</select>
<div id="search"><input type="submit" name="search" value="Buscar"></div>
<div class="clear" ></div>
</form>
</section>
<?php else:?>
<section id="filtrados">
<?php
include 'paginador_resultados.php';
?>
</section>
<?php endif; ?>
<br /><hr><br />
<?php echo $utilidades->footer(); ?>
<div class="clear"></div>
</div>
</body>
</html>
en este es donde proceso todo:
Código PHP:
Ver original<?php
require_once '../clases/connection.class.php';
require_once '../clases/reportes.class.php';
$connection=new Connection();
$reportes=new reportes($connection);
$RegistrosAMostrar=20;
//estos valores los recibo por GET
$RegistrosAEmpezar=($_GET['pag']-1)*$RegistrosAMostrar;
$PagAct=$_GET['pag'];
//caso contrario los iniciamos
}else{
$RegistrosAEmpezar=0;
$PagAct=1;
}
?>
<h1>Se encontraron <?php echo $reportes->encontrados($_POST['desde'],$_POST['hasta']); ?> coincidencias a tu búsqueda.</h1>
<table width="100%">
<thead>
<tr>
<th>Folio</th>
<th>Fecha</th>
<th>Folio fiscal</th>
<th>Cliente</th>
<th>Subtotal</th>
<th>Iva</th>
<th>Total</th>
<th>PDF</th>
</tr>
</thead>
<?php
if($filtrado=$reportes->listarResultados($_POST['desde'],$_POST['hasta'],$RegistrosAEmpezar,$RegistrosAMostrar)):
foreach($filtrado as $filtro): ?>
<tbody>
<tr>
<td><?php echo $filtro->folio; ?></td>
<td><?php echo $filtro->fecha; ?></td>
<td><?php echo $filtro->folioFiscal; ?></td>
<td><?php echo $filtro->cliente; ?></td>
<td>
<?php echo "$ ".number_format($filtro->subtotaFactura,2,'.',','); ?></td>
<td>
<?php echo "$ ".number_format($filtro->ivaFactura,2,'.',','); ?></td>
<td>
<?php echo "$ ".number_format($filtro->totalFactura,2,'.',','); ?></td>
<td><?php echo $filtro->nombrePDF; ?></td>
</tr>
</tbody>
<?php endforeach;
endif; ?>
<tfoot>
<tr>
<td colspan="6"> </td>
<td>
<?php echo "$ ".number_format($filtro->totalGeral,2,'.',','); ?></td>
</tr>
</tfoot>
</table>
<?php
//******--------determinar las p‡ginas---------******//
$NroRegistros=$reportes->encontrados($_POST['desde'],$_POST['hasta']);
$PagAnt=$PagAct-1;
$PagSig=$PagAct+1;
$PagUlt=$NroRegistros/$RegistrosAMostrar;
//verificamos residuo para ver si llevar‡ decimales
$Res=$NroRegistros%$RegistrosAMostrar;
// si hay residuo usamos funcion floor para que me
// devuelva la parte entera, SIN REDONDEAR, y le sumamos
// una unidad para obtener la ultima pagina
if($Res>0) $PagUlt=floor($PagUlt)+1;
//desplazamiento
?>
<a onclick="Pagina('1')" >Primero</a>
<?php if($PagAct>1) ?><a onclick="Pagina('<?php echo $PagAnt; ?>')">Anterior</a>
<strong>Pagina <?php echo $PagAct."/".$PagUlt ?></strong>
<?php if($PagAct<$PagUlt) ?><a onclick="Pagina('<?php echo $PagSig; ?>')" >Siguiente</a>
<a onclick="Pagina('<?php echo $PagUlt; ?>')" >Ultimo</a>
y este es el archivo ajax que hace el proceso.
Código Javascript
:
Ver originalfunction objetoAjax(){
var xmlhttp=false;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(E){
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function Pagina(nropagina){
//donde se mostrar‡ los registros
divContenido = document.getElementById('filtrados');
ajax=objetoAjax();
//uso del medoto GET
//indicamos el archivo que realizar‡ el proceso de paginar
//junto con un valor que representa el nro de pagina
ajax.open("GET", "paginador_resultados.php?pag="+nropagina);
divContenido.innerHTML= '<img src="../img/cargando.gif">';
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
//mostrar resultados en esta capa
divContenido.innerHTML = ajax.responseText
}
}
//como hacemos uso del metodo GET
//colocamos null ya que enviamos
//el valor por la url ?pag=nropagina
ajax.send(null)
}
He intentado de todo pero no logro hacer que funcione correctamente.
De antemano muchas gracias