PHP - Problema con Paginacion

 
Vista:

Problema con Paginacion

Publicado por cristian (42 intervenciones) el 09/09/2013 19:12:55
Estimados tengo el siguiente problema,
veran tengo 2 cajas de texto y hago la busqueda por rango de fechas, hago la busqueda y el resultado es correcto y la cantidad de paginas tambien, pero al momento de dar click a uno de las paginas me bota a la pagina de la fecha actual y se baja la cantidad de paginas.

con este codigo hago esa paginacion:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Total:
<?= $Num_Rows;?>
,
<?=$Num_Pages;?>
&nbsp;Pagin&aacute;s :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Atras</a> ";
}
 
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Adelante>></a> ";
}


algo tiene que ver el echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Atras</a> ";
cuando hago una busqueda por rango de fechas, en el navegador aparece lo siguiente:
http://localhost/visitasVersion2_Produccion/Reporte/reportedevisita.php?txtFecha1=01%2F09%2F2013&txtFecha2=09%2F09%2F2013&buscar=Buscar

pero como les comentaba, al dar click a una de las muchas paginas se baja a:
http://localhost/visitasVersion2_Produccion/Reporte/reportedevisita.php?Page=2
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Problema con Paginacion

Publicado por xve (6935 intervenciones) el 09/09/2013 21:16:12
Hola Cristian, no se muy bien como lo tienes programado, pero cuando cambias de pagina, únicamente pasar el numero de página, no pasas los valores seleccionados en los desplegables... los guardas en variables de sesión?

Si no los guardas y no pasas dichos parámetros de alguna manera, la pagina no recuerda la anterior selección.

Coméntanos, ok?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Problema con Paginacion

Publicado por cristian (42 intervenciones) el 09/09/2013 21:22:09
Este es mi codigo programado:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">
<head>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 charset=windows-1252>
<META NAME="language" CONTENT="ES">
<title>Reporte Online</title>
<link href="../calendario/css/calendario.css" type="text/css" rel="stylesheet">
<script src="../calendario/js/calendar.js" type="text/javascript"></script>
<script src="../calendario/js/calendar-es.js" type="text/javascript"></script>
<script src="../calendario/js/calendar-setup.js" type="text/javascript"></script>
 
<style type="text/css">
        body {
	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #333;
	text-decoration: none;
	line-height: 16px;
	background-color: #FFFFFF;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
form {
	line-height: 30px;
}
 
.confirm {
	color: #036;
	font-style: italic;
}
.style3 {color: #000000}
</style>
</head>
<body>
<div class="AreaDesarrollo">
<center><div class="a"></div>	</center>
<center>
 
<?php
/// set fechas ////
$fechaini = "";
$fechafin = "";
 
if ($_GET['txtFecha1'] == ""){
$fechaini = date("d/m/Y");
}else{
$fechaini = $_GET['txtFecha1'];
}
 
if ($_GET['txtFecha2'] == ""){
$fechafin = date("d/m/Y");
}else{
$fechafin = $_GET['txtFecha2'];
}
 
//////////////////
 
?>
  <form method="GET" name="formulario" action="<?=$_SERVER['PHP_SELF']?>">
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="3" bgcolor="#FFFFFF">
 
    <tr>
      <td width="875" colspan="10" style="font-family:'Arial Narrow';font-size:12px"><img src="../images/cab_visitas.jpg" width="900" height="63" /></td>
    </tr>
 
  <tr>
    <td colspan="10" align="center" style="color:#ffffff">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="10" align="center" style="color:#ffffff"><div align="left">Fecha Inicio :
        <input name="txtFecha1" type="text" id="txtFecha1" value="<?php echo $fechaini; ?>" readonly="true" />
        <img src="../calendario/ima/calendario.png" width="16" height="16" border="0" title="Fecha Inicial" id="lanzador" />
		<script type="text/javascript"> Calendar.setup({ inputField:"txtFecha1",ifFormat:"%d/%m/%Y",button:"lanzador"}); </script>
		Fecha Fin:
                <input name="txtFecha2" type="text" id="txtFecha2" value="<?php echo $fechafin; ?>" readonly="true" />
                <img src="../calendario/ima/calendario.png" width="16" height="16" border="0" title="Fecha Inicial" id="lanzador2" />
				<script type="text/javascript"> Calendar.setup({ inputField:"txtFecha2",ifFormat:"%d/%m/%Y",button:"lanzador2"}); </script>
                <input type="submit" class="FormSubmitReg" name="buscar" value="Buscar" />
                <input type="button" class="FormSubmitReg" name="buscar2" value="Regresar" onclick="location.href='../index.php'" />
    </div></td>
    </tr>
  <tr>
    <td colspan="10" align="center" style="color:#ffffff">
 
 
 
 
 
 
	<?php
	require_once("../conexion/conexion.php");
	$strSQL="SP_REPORTE_ONLINE '$fechaini', '$fechafin'";
	///////////////////////////////
 
	$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$Num_Rows = mssql_num_rows($objQuery);
 
	$Per_Page = 10;   // Per Page  
 
	$Page = $_GET["Page"];
	if(!$_GET["Page"])
	{
	$Page=1;
	}
 
	$Prev_Page = $Page-1;
	$Next_Page = $Page+1;
 
	$Page_Start = (($Per_Page*$Page)-$Per_Page);
	if($Num_Rows<=$Per_Page)
	{
	$Num_Pages =1;
	}
	else if(($Num_Rows % $Per_Page)==0)
	{
	$Num_Pages =($Num_Rows/$Per_Page) ;
	}
	else
	{
	$Num_Pages =($Num_Rows/$Per_Page)+1;
	$Num_Pages = (int)$Num_Pages;
	}
	$Page_End = $Per_Page * $Page;
	IF ($Page_End > $Num_Rows)
	{
	$Page_End = $Num_Rows;
	}
	///////////////////////////////
 
 
  //while($f=mssql_fetch_array($re)){
	  for($i=$Page_Start;$i<$Page_End;$i++)
{
	?>
      <p></p>
      <p> </p>
      <center>
        <table width="101%" height="30"  border="1" align="center" cellpadding="3" cellspacing="0">
          <tr bgcolor="#CCCCCC">
            <th width="9%"><div align="left"><span class="style3">Vistante</span></div></th>
            <th width="9%"><span class="style3">Documento</span></th>
            <th width="11%"><span class="style3">Remitente</span></th>
            <th width="11%"><span class="style3">Motivo</span></th>
            <th width="10%"><span class="style3">Sede</span></th>
            <th width="10%"><span class="style3">Oficina</span></th>
            <th width="10%"><span class="style3">Empleado</span></th>
            <th width="10%"><span class="style3">Lugar reuni&oacute;n </span></th>
            <th width="10%"><span class="style3">Fecha Ingreso </span></th>
            <th width="10%"><span class="style3">Fecha Salida </span></th>
            </tr>
          <?
for($i=$Page_Start;$i<$Page_End;$i++)
{
    if ($color == "#e8f3ff"){
			$color = "#FFFFFF";
	  }else{
			$color = "#e8f3ff";
	  }
	  if ($color == ""){
			$color = "#FFFFFF";
	  }
?>
          <tr bgcolor="<?=$color?>" onMouseOver="this.style.backgroundColor='#BFDEFF';" onMouseOut="this.style.backgroundColor='<?=$color?>'">
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"Visitante");?>
            </span></td>
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"Documento");?>
            </span></td>
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"remitente");?>
            </span></td>
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"nombotivo");?>
            </span></td>
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"nomsede");?>
            </span></td>
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"nomoficina");?>
            </span></td>
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"nomempleado");?>
            </span></td>
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"nomreunion");?>
            </span></td>
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"fingreso");?>
            </span></td>
            <td><span class="style3">
              <?=mssql_result($objQuery,$i,"hsalida");?>
            </span></td>
            </tr>
          <?
}
?>
        </table>
      </center>
      <?php }?>
      <p></p>
      <span class="style3"><br />
Total:
<?= $Num_Rows;?>
,
<?=$Num_Pages;?>
&nbsp;Pagin&aacute;s :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Atras</a> ";
}
 
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Adelante>></a> ";
}
mssql_close($cnx);  ?>
      </span></td>
  </tr>
</table>
 
<div>
 
  </form>
</body>
</html>
cuando paso a la siguiente pagina, no me muestra los resultados de la busqueda anterior.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Problema con Paginacion

Publicado por xve (6935 intervenciones) el 10/09/2013 07:09:13
Hola Cristian, lo que tienes que hacer, es pasar las fechas... algo así:
1
echo " <a href='".$_SERVER[SCRIPT_NAME]."?Page=".$Prev_Page."&txtFecha1=".$_GET['txtFecha1']."&txtFecha2=".$_GET['txtFecha2']."'><< Atras</a>

Coméntanos, ok?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Problema con Paginacion

Publicado por cristian (42 intervenciones) el 10/09/2013 17:00:31
Gracias Doctor,
Mas bien faltaba una linea mas.

1
echo "[<a href='".$_SERVER[SCRIPT_NAME]."?Page=".$i."&txtFecha1=".$_GET['txtFecha1']."&txtFecha2=".$_GET['txtFecha2']."'><< $i</a>]";
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar