Good morning, I have the following program that makes me look up a mysql table and also generates a report in excel:
The problem is that when I want to make a report, it does it but in addition to the report table, it adds more things ..
As you can see, the table of the report that is what I need is the one that is shaded, but in addition to that table the document that I download comes with more things. HOW DO I MAKE ON THE EXCEL FILE ONLY THE REPORT TABLE APPEARS?
Next I attach the code
This is the index, here I include the php program that connects me to the database, the php that makes me search for a specific data hosted in the database and the php that I downloaded the report to excel, here are also the input, the submit that performs a certain search, the submit that I download the excel report and the table where the data I want is printed:
<?php
include('conex.php');
?>
<?php
include('repor.php');
?>
<title>busqueda</title>
<p>
<form name="form1" method="POST" action="busqueda.php" id="cdr"
onKeypress="if(event.keyCode == 13) event.returnValue = false;">
<h2>Buscar Usuario</h2>
<input name="busca" type="text" id="busqueda" placeholder="Ingrese el día">
<input name="mes" type="text" id="mesqueda" placeholder="Ingrese el mes">
<input name="año" type="text" id="añoqueda" placeholder="Ingrese el año">
<br><br>
<input type="submit" name="submit" value="Buscar">
<input type="submit" name="reporte" value="Reporte">
</p>
</form>
<table width="500" border="1" id="tab">
<tr>
<td width="60">Día</td>
<td width="90">Mes</td>
<td width="90">Año</td>
</tr>
<?php
include('busq.php');
?>
</table>
This is the php that searches the database:
<?php
error_reporting(E_ALL ^ E_NOTICE);
$busca=$_POST['busca'];
$mes=$_POST['mes'];
$año=$_POST['año'];
$con->real_query("SELECT * FROM entrada WHERE dia like '%$busca%' and mes
LIKE '%$mes%' and anio like '%$año%'");
$resultado= $con->use_result();
while($muestra=$resultado->fetch_assoc()){
echo'<tr>';
echo'<td>'.$muestra['dia'].'</td>';
echo'<td>'.$muestra['mes'].'</td>';
echo'<td>'.$muestra['anio'].'</td>';
echo'</tr>';
}
?>
And this is the php that makes the report to excel, in this case I have it for me to make the report depending on what I write in the input day:
<?php
error_reporting(E_ALL ^ E_NOTICE);
include('conex.php');
$output='';
$busca=$_POST['busca'];
if(isset($_POST['reporte'])) {
$sql = "SELECT * FROM entrada where dia like '%$busca%'";
$result= mysqli_query($con,$sql);
if(mysqli_num_rows($result) > 0)
{
$output .= '
<table class="table" bordered="1">
<tr>
<th>Dia</th>
<th>Mes</th>
<th>Anio</th>
</tr>
';
while ($row = mysqli_fetch_array($result)) {
$output .= '
<tr>
<td>'.$row["dia"].'</td>
<td>'.$row["mes"].'</td>
<td>'.$row["anio"].'</td>
</tr>
';
}
$output .= '</table>';
header("Content-Type: application/xls");
header("Content-Disposition:attachment; filename=download.xls");
echo $output;
}
}
?>
Any help will be very grateful!