Tengo esta tabla en php y quiero que al presionar el Num de Folio me descargue el archivo ".xls" del servidor con el nombre según su Folio por ejemplo, "Si presiono el folio 130, me tiene que descargar el archivo 130.xls"
Éste es mi código:
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>';
Y esto lo tengo para descargar el .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);