I have this table in php and I want to press the Folio Num to download the file ".xls" from the server with the name according to its Folio for example, "If I press the folio 130, I have to download the file 130 .xls "
This is my code:
foreach ($query as $valor) {
echo '<tr> <td nowrap style="width: 200px; text-align:center;"><a target="_self" href="javascript:SelCalen(\''. $valor[0] .'\',\''. $valor[2] .'\',\''. $v01 .'\');" >' . $valor[0] . '</a></td> <td style="width: 100px;" nowrap class="center">' . $valor[1] . '</td> <td nowrap style="width: 200px; text-align:left;">' . $valor[2] . '</td> <td nowrap class="center"> ' .$valor[3] . '</td> <td nowrap class="center">' . $valor[4] . '</td> </tr>';
}
echo '</tbody>';
And this I have to download the .xls
// Definimos el nombre de archivo a descargar.
$filename = "100.xls";
// Ahora guardamos otra variable con la ruta del archivo
$file = "functions/".$filename;
// Aquí, establecemos la cabecera del documento
header("Content-Description: Descargar imagen");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/force-download");
header("Content-Length: " . filesize($file));
header("Content-Transfer-Encoding: binary");
readfile($file);