Thanks for your time: but I can not make the correct query and print the result I leave the complete code of the search
assists
Columns: (id, student_id, area, bimester, state, management, month, day)
students
Columns: (id, apaterno, amaterno, names, level, course, parallel, management)
The search form is on the same page:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" class="form-inline">
<input type="hidden" name="nivel" value="<?php echo $nivel;?>">
<input type="hidden" name="curso" value="<?php echo $curso;?>">
<input type="hidden" name="paralelo" value="<?php echo $paralelo;?>">
<input type="hidden" name="gestion" value="<?php echo $gestion;?>">
<div class="form-group">
Bimestre:
<select name="bimestre" class="form-control">
<option value=" ">...</option>
<option value="1BIM">1 Bimestre</option>
<option value="2BIM">2 Bimestre</option>
<option value="3BIM">3 Bimestre</option>
<option value="4BIM">4 Bimestre</option>
</select> </div> <div class="form-group">
Materia:
<select name="area" class="form-control">
<option value=" ">Seleccionar</option>
<?php
include("../conexion.php");
$consultaf="SELECT area FROM areas";
$resultado=$link->query($consultaf);
while ($row=$resultado->fetch_array()) {
$area=$row['area'];
echo "<option value='".utf8_encode($area)."'>".utf8_encode($area)."</option>";
// echo $area;
}
?>
</select>
</div>
|| <button type="submit" name="buscar" class="btn btn-warning "> Buscar Informe +</button>
</form>
I publish the code that worked thanks to teachers
This is the if where the report is searched on the same page and print the results:
<?php
if(isset($_GET['buscar'])){
//$name = $_POST['name'];
include("../conexion.php");
$nivel=$_GET['nivel'];
$curso=$_GET['curso'];
$paralelo=$_GET['paralelo'];
$gestion=$_GET['gestion'];
$bimestre=$_GET['bimestre'];
$area=$_GET['area'];
?>
<form action="asis_areas_pdf.php" method="post">
<table class="table table-bordered table-striped table-hover">
<tbody>
<tr>
<td colspan="6">RESUMEN DE ASISTENCIA del Curso: <?php echo $curso." ".$paralelo." ".$nivel;?> </td>
</tr>
<tr>
<td>N°</td>
<td class="warning"><H3>APELLIDOS Y NOMBRES</H3></td>
<td class="danger">Asistencias</td>
<td class="warning">Faltas</td>
<td class="info">Licencias</td>
<td class="success">Abandonos</td>
<td class="success">Total</td>
</tr>
<?php
$tabla1="alumnos";
$tabla2="asistencia";
$consulta="SELECT $tabla1.id,$tabla1.apaterno,$tabla1.amaterno,$tabla1.nombres,$tabla1.nivel,$tabla1.curso, $tabla1.paralelo,$tabla1.gestion,
sum($tabla2.estado='P') as totalP,
sum($tabla2.estado='L') as totalL,
sum($tabla2.estado='F') as totalF,
sum($tabla2.estado='A') as totalA,
count($tabla2.estado) as total
FROM $tabla1 INNER JOIN $tabla2 ON $tabla1.id=$tabla2.id_alumno
WHERE $tabla1.nivel='$nivel' AND $tabla1.curso='$curso' AND
$tabla1.paralelo='$paralelo' AND $tabla2.gestion='$gestion' AND
$tabla2.bimestre='$bimestre' AND $tabla2.area='$area'
GROUP BY $tabla1.id ORDER BY $tabla1.apaterno,$tabla1.amaterno,$tabla1.nombres ASC";
if ($resultados=$link->query($consulta)) {
while ($row=$resultados->fetch_array()) {
$id=$row['id'];
$apaterno=$row['apaterno'];
$amaterno=$row['amaterno'];
$nombres=$row['nombres'];
$gestion=$row['gestion'];
$totalP=$row['totalP'];
$totalL=$row['totalL'];
$totalF=$row['totalF'];
$totalA=$row['totalA'];
$total=$row['total'];
echo "<tr>";
echo " <td>".$id."</td>
<td>".$apaterno." ".$amaterno." ".$nombres."</td>
<td>".$totalP."</td>
<td>".$totalF."</td>
<td>".$totalL."</td>
<td>".$totalA."</td>
<td>".$total."</td>";
echo "</tr>";
}}
?>
This is the code that worked, thank you all for your help, and the result is as follows: