Lectores del foro tengo el siguiente problema , tengo un buscador en el cual el criterio de busqueda es la fecha , el problema es que intento implementar que los resultados que me muestre el buscador sean exportados a un formato excel , mi duda es que el parametro al archivo exportar excel lo paso bajo el parametro $GET pero no me sale ningun resultado, expongo el codigo espero puedan brindarme su ayuda .
buscar.php
Código PHP:
Ver original<?php
if ($_POST['buscador']){
$buscar = $_POST['palabra'];
// Si está vacío
echo "No se han ingresado datos a Buscar";
}
else{
$sql = "SELECT
unifica_proyectos.id,
unifica_proyectos.nombreencuesta,
unifica_proyectos.fecha,
unifica_proyectos.rut,
unifica_proyectos.nombreevaluador,
unifica_proyectos.idregion,
unifica_proyectos.coordinador,
unifica_proyectos.mail,
regiones.region,
regiones.idregion
FROM unifica_proyectos
INNER JOIN regiones ON unifica_proyectos.idregion = regiones.idregion WHERE fecha like '%$buscar%' ORDER BY id DESC";
do {
$fecha=$row['fecha'];
$rut=$row['rut'];
echo "<table class=cambia-color>";
echo "<tr>";
echo "<td width=20%>$nombreencuesta</td>";
echo "<td width=10%>$fecha</td>";
echo "<td width=10%>$rut</td>";
echo "<td width=20%>$nombreevaluador</td>";
echo "<td width=10%>$region</td>";
echo "<td width=10%>$coordinador</td>";
echo "<td width=10%>$mail</td>";
echo "</table>";
}
}
else {
echo "No se encontraron resultados para: <b>$buscar</b>";
}
}
}
?>
<a href="exportar_excel.php?<?php echo $buscar;?>">Exportar</a>
exportar_excel.php
Código PHP:
Ver original$buscar=$_GET['palabra'];
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header('Content-Transfer-Encoding: none'); header('Content-Type: application/vnd.ms-excel'); // This should work for IE & Opera header('Content-type: application/x-msexcel'); // This should work for the rest header('Content-Disposition: attachment; filename="nombre.xls"');
$sql = "SELECT
unifica_proyectos.id,
unifica_proyectos.nombreencuesta,
unifica_proyectos.fecha,
unifica_proyectos.rut,
unifica_proyectos.nombreevaluador,
unifica_proyectos.idregion,
unifica_proyectos.coordinador,
unifica_proyectos.mail,
regiones.region,
regiones.idregion
FROM unifica_proyectos
INNER JOIN regiones ON unifica_proyectos.idregion = regiones.idregion WHERE fecha='".$buscar."'";
$fecha=$row['fecha'];
$rut=$row['rut'];
echo '<table xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
<tr>
<td>$nombreencuesta</td>
<td>$fecha</td>
<td>$rut</td>
<td>$nombreevaluador</td>
<td>$region</td>
<td>$coordinador</td>
<td>$mail</td>
</tr>
</table>';
}
saludos y de antemano gracias