PHP - Paginacion

 
Vista:
sin imagen de perfil
Val: 20
Ha aumentado su posición en 4 puestos en PHP (en relación al último mes)
Gráfica de PHP

Paginacion

Publicado por David (7 intervenciones) el 09/09/2019 23:29:18
Buenas tardes

me tratado de hacer una paginación pero tengo problemas con los bindParam, estoy iniciando quiero aclarar e igual algo estoy haciendo algo mal, es todo mi codigo

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
<?php include("includes/header.php")?>
<?php
 
	include("db.php");
    if(!isset($_SESSION)) {session_start();}
 
    /*if(!isset($_SESSION['rol'])){
        header('location: index.php'); }

       else{
        if($_SESSION['rol'] != 1){
            header('location: index.php');} }*/
// paginacion
 
 $sql_registe = mysqli_query($conn, "SELECT COUNT(*) as total_registro FROM reporte WHERE id");
            $result_register = mysqli_fetch_array($sql_registe);
            $total_registro = $result_register['total_registro'];
            $reportexpagina = 5;
            $paginas = ceil ($total_registro / $reportexpagina);
?>
 
 
<title>Consulta de registros</title>
 
   <div id="contenedor">
 
		<div id="header">
			<div class="logo"> <img src="img/IGSA.png" width="97" height="99"> </div>
			<div class="bienvenido">Reportes </div>
			<div class="session"> <a href="cerrar.php">Cerrar sesion</a></div>
 
           </header>
	    </div>
 
 
	<div id="contenido">
 
		<div id="aside">
			<aside>
	           <ul>
			   <li><a href="index.php"> INICIO </a></li>
		       <li><a href="newreport.php"> Nuevo reporte </a></li>
		       <li><a href="consulta.php">  Consultar reporte     </a></li>
			   <li><a href="newuser.php">   Nuevo usuario </a></li>
			   <li><a href="useredit.php"> Consultar </a></li>
			   <!-- 
                     
               <li><a href="newequipo.php"> Nuevo equipo</a></li>
			   <li><a href="equipoedit.php"> Editar Equipo</a></li>
			   <li><a href="newarea.php"> Nueva area</a></li>
			   <li><a href="areaedit.php">Editar area</a></li>
		       </ul>

              -->
	        </aside>
		</div>
 
		<div id="section">
		<section>
        <div class="col-mod-10">
			       <?php  if(isset($_SESSION['message'])){ ?>
					<div class="alert alert-<?= $_SESSION['message_type']; ?> alert-dismissible fade show" role="alert">
                    <?= $_SESSION['message'] ?>
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                     </button>
                     </div>
					<?php session_unset(); } ?>
 
 
 
			 <form action='consulta.php'  method='POST'>
				<input type="text" name='filtro' placeholder="buscar">
				<input type="submit" class="btn btn-success" value="buscar" name='buscar'>
			 </form>
		   <table class="table table-bordered">
			 <thead class="display">
			    <tr>
				   <th> Folio</th>
					<th> fecha apertura</th>
				   <th> Asignada</th>
					<th> Titulo</th>
				   <th> equipo</th>
				   <th> asignada</th>
				   <th> prioridad</th>
					<th> status</th>
				   <th>Action</th>
			    </tr>
			 </thead>
			   <tbody>
 
				   <?php
 
				 if(!$_GET){
				  header('location:consulta.php?pagina=1');
			        }if ($_GET['pagina']>$paginas || $_GET['pagina'] <= 0){
		         header('location:consulta.php?pagina=1');
			        }
			 $iniciar = intval(($_GET['pagina']-1)*$reportexpagina);
				   echo $iniciar;
 
		if(isset($_POST["buscar"])){
 
		     $filtro = $_POST['filtro'];
			 $query_cosultareport ="SELECT reporte.id, reporte.f_apertura, reporte.username, reporte.caso,
	                               equipo.equipo,  asignada.asignada, prioridad.prioridad, status.status
					   FROM equipo 
					   INNER JOIN reporte   ON reporte.equipo=equipo.idequipo
					   INNER JOIN asignada  ON reporte.asignada=asignada.idasignada
					   INNER JOIN prioridad ON reporte.prioridad=prioridad.idprioridad
					   INNER JOIN status    ON reporte.status=status.idstatus
					   WHERE reporte.id LIKE '%$filtro%' OR reporte.status LIKE '%$filtro%'
					   ORDER BY reporte.id DESC";
				   }else{
 
	         $query_cosultareport = "SELECT reporte.id, reporte.f_apertura, reporte.username, reporte.caso,
	                               equipo.equipo,  asignada.asignada, prioridad.prioridad, status.status
					   FROM equipo 
					   INNER JOIN reporte   ON reporte.equipo=equipo.idequipo
					   INNER JOIN asignada  ON reporte.asignada=asignada.idasignada
					   INNER JOIN prioridad ON reporte.prioridad=prioridad.idprioridad
					   INNER JOIN status    ON reporte.status=status.idstatus
					   ORDER BY reporte.id DESC
					   LIMIT :inici, :nreportes";
				   }
				   echo $query_cosultareport;
 
			 $sentencia_reportes= $conn-> prepare($query_cosultareport);
			 $sentencia_reportes->bindParam(':inici', $iniciar, PDO::PARAM_INT);
			 $sentencia_reportes->bindParam(':nreportes', $reportexpagina, PDO::PARAM_INT);
			 $sentencia_reportes->execute();
			 $resultado_reporte =$sentencia_reportes -> fetchAll();
 
			 $resulta_reporte = mysqli_query($conn, $query_cosultareport) ; //ejecuta la consulta
 
				   while($row = mysqli_fetch_array($resulta_reporte))
				       {
 
                       ?>
				   <tr>
				       <td><?php echo $row['id'] ?></td>
					   <td><?php echo $row['f_apertura'] ?></td>
					   <td><?php echo $row['username'] ?></td>
					   <td><?php echo $row['caso'] ?></td>
					   <td><?php echo $row['equipo'] ?></td>
					   <td><?php echo $row['asignada'] ?></td>
					   <td><?php echo $row['prioridad'] ?></td>
					   <td><?php echo $row['status'] ?></td>
					   <td>
					      <a href = "edit_registro.php?id=<?php echo $row['id']?>"><i class="fas fa-marker"></i></a>
						  <a href = "delete_registro.php?id=<?php echo $row['id']?>"><i class="far fa-trash-alt"></i></a>
					   </td>
				   </tr>
 
				   <?php  } ?>
 
			   </tbody>
		   </table>
	     </div>
 
 
<nav aria-label="Page navigation">
   <ul class="pagination">
      <li class="page-item
				 <?php echo $_GET['pagina']<=1? 'disabled':'' ?> 
				 ">
		  <a class="page-link" href="consulta.php?pagina=<?php echo $_GET['pagina']-1 ?>">
			  Anterior
		  </a></li>
 
	  <?php for($i=0;$i<$paginas;$i++): ?>
 
	   <li class="page-item <?php echo $_GET['pagina']==$i+1 ?'active' : '' ?>">
		   <a class="page-link" href="consulta.php?pagina=<?php echo $i+1 ?>">
		   <?php echo $i+1 ?></a>
	   </li>
	  <?php endfor ?>
 
      <li class="page-item
				 <?php echo $_GET['pagina']>=$paginas? 'disabled':'' ?> 
				 ">
		  <a class="page-link" href="consulta.php?pagina=<?php echo $_GET['pagina']+1 ?>">
		  Siguiente</a></li>
  </ul>
</nav>
 
 
	    </section>
		</div>
 
  <?php include("includes/footer.php")?>

*** este es el error que me aparece

Captura-de-Pantalla-2019-09-09-a-las-4.26.10-p-m

gracias y saludos
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 Alejandro
Val: 1.634
Plata
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Paginacion

Publicado por Alejandro (839 intervenciones) el 10/09/2019 00:38:15
  • Alejandro se encuentra ahora conectado en el
  • chat de PHP
En la primer consulta no existen los parámetros :inici, :nreportes
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