I am new to this world, I downloaded a source code to create a small project to manage a list of people with about 500 records, so far I have managed to modify it to my requirements, now in the following code I show a table where I list the records of my database 15 records maximum per page "I understand it is called paginacion" now I have tried to include a search engine at least by cedula and show it to me in the same table without success, I come to you the experts so that give me some clue how to integrate this search engine, thank you very much for your help and understanding "I'm a novice in the area"
<?php if( $_SESSION['nombre']!="" && $_SESSION['clave']!="" && $_SESSION['tipo']=="admin"){ ?>
<div class="container">
<div class="row">
<div class="col-sm-10">
<p class="lead text-info">Listado General el cual podra modificar e imprimir.</p>
</div>
<div class="col-sm-10">
</div>
</div>
</div>
<?php
if(isset($_POST['id_del'])){
$id = MysqlQuery::RequestPost('id_del');
if(MysqlQuery::Eliminar("funcionarios", "id='$id'")){
echo '
<div class="alert alert-info alert-dismissible fade in col-sm-3 animated bounceInDown" role="alert" style="position:fixed; top:70px; right:10px; z-index:10;">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="text-center">FUNCIONARIO ELIMINADO</h4>
<p class="text-center">
El funcionario fue eliminado del sistema con exito
</p>
</div>
';
}else{
echo '
<div class="alert alert-danger alert-dismissible fade in col-sm-3 animated bounceInDown" role="alert" style="position:fixed; top:70px; right:10px; z-index:10;">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="text-center">OCURRIÓ UN ERROR</h4>
<p class="text-center">
No hemos podido eliminar el funcionario
</p>
</div>
';
}
}
?>
<div class="container">
<li><a href="./admin.php?view=listgenadmin&funcionarios=result"><i class="fa fa-search"></i> Buscar Cedula </a></li>
<br>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<?php
$mysqli = mysqli_connect(SERVER, USER, PASS, BD);
mysqli_set_charset($mysqli, "utf8");
$pagina = isset($_GET['pagina']) ? (int)$_GET['pagina'] : 1;
$regpagina = 15;
$inicio = ($pagina > 1) ? (($pagina * $regpagina) - $regpagina) : 0;
if(isset($_GET['funcionarios'])){
if($_GET['funcionarios']=="all"){
$consulta="SELECT SQL_CALC_FOUND_ROWS * FROM funcionarios LIMIT $inicio, $regpagina";
}elseif($_GET['funcionarios']=="result"){
$consulta="SELECT SQL_CALC_FOUND_ROWS * FROM funcionarios WHERE cedula='' LIMIT $inicio, $regpagina";
}else{
$consulta="SELECT SQL_CALC_FOUND_ROWS * FROM funcionarios LIMIT $inicio, $regpagina";
}
}else{
$consulta="SELECT SQL_CALC_FOUND_ROWS * FROM funcionarios LIMIT $inicio, $regpagina";
}
$selticket=mysqli_query($mysqli,$consulta);
$totalregistros = mysqli_query($mysqli,"SELECT FOUND_ROWS()");
$totalregistros = mysqli_fetch_array($totalregistros, MYSQLI_ASSOC);
$numeropaginas = ceil($totalregistros["FOUND_ROWS()"]/$regpagina);
if(mysqli_num_rows($selticket)>0):
?>
<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th class="text-center">#</th>
<th class="text-center">Cedula</th>
<th class="text-center">Nombres</th>
<th class="text-center">Apellidos</th>
<th class="text-center">Rango</th>
<th class="text-center">Fecha Ingreso</th>
<th class="text-center">Ubicacion</th>
<th class="text-center">Acciones</th>
</tr>
</thead>
<tbody>
<?php
$ct=$inicio+1;
while ($row=mysqli_fetch_array($selticket, MYSQLI_ASSOC)):
?>
<tr>
<td class="text-center"><?php echo $ct; ?></td>
<td class="text-center"><?php echo $row['cedula']; ?></td>
<td class="text-center"><?php echo $row['nombres']; ?></td>
<td class="text-center"><?php echo $row['apellidos']; ?></td>
<td class="text-center"><?php echo $row['rango']; ?></td>
<td class="text-center"><?php echo $row['fecha_ingreso']; ?></td>
<td class="text-center"><?php echo $row['ubicacion']; ?></td>
<td class="text-center">
<a href="admin.php?view=funcionario&id=<?php echo $row['id']; ?>" class="btn btn-sm btn-primary"><i class="fa fa-eye" aria-hidden="true"></i></a>
<a href="./lib/pdf.php?id=<?php echo $row['id']; ?>" class="btn btn-sm btn-success" target="_blank"><i class="fa fa-print" aria-hidden="true"></i></a>
<a href="admin.php?view=ticketedit&id=<?php echo $row['id']; ?>" class="btn btn-sm btn-warning"><i class="fa fa-pencil" aria-hidden="true"></i></a>
</td>
</tr>
<?php
$ct++;
endwhile;
?>
</tbody>
</table>
<?php else: ?>
<h2 class="text-center">No hay funcionarios registrados en el sistema</h2>
<?php endif; ?>
</div>
<?php
if($numeropaginas>=1):
if(isset($_GET['funcionarios'])){
$ticketselected=$_GET['funcionarios'];
}else{
$ticketselected="all";
}
?>
<nav aria-label="Page navigation" class="text-center">
<ul class="pagination">
<?php if($pagina == 1): ?>
<li class="disabled">
<a aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<?php else: ?>
<li>
<a href="./admin.php?view=listgenadmin&funcionarios=<?php echo $ticketselected; ?>&pagina=<?php echo $pagina-1; ?>" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<?php endif; ?>
<?php
for($i=1; $i <= $numeropaginas; $i++ ){
if($pagina == $i){
echo '<li class="active"><a href="./admin.php?view=listgenadmin&funcionarios='.$ticketselected.'&pagina='.$i.'">'.$i.'</a></li>';
}else{
echo '<li><a href="./admin.php?view=listgenadmin&funcionarios='.$ticketselected.'&pagina='.$i.'">'.$i.'</a></li>';
}
}
?>
<?php if($pagina == $numeropaginas): ?>
<li class="disabled">
<a aria-label="Previous">
<span aria-hidden="true">»</span>
</a>
</li>
<?php else: ?>
<li>
<a href="./admin.php?view=listgenadmin&funcionarios=<?php echo $ticketselected; ?>&pagina=<?php echo $pagina+1; ?>" aria-label="Previous">
<span aria-hidden="true">»</span>
</a>
</li>
<?php endif; ?>
</ul>
</nav>
<?php endif; ?>
</div>
</div>
</div><!--container principal-->
Sorry this page is only for administrators Log in as administrator to access