1 changed files with 59 additions and 0 deletions
@ -0,0 +1,59 @@ |
|||||
|
<?php |
||||
|
session_start(); |
||||
|
|
||||
|
@include 'cgi-bin/conn.conn'; |
||||
|
|
||||
|
$conn=mysqli_connect($DATAhst,$DATAusr,$DATApwd,$DATAdtb); |
||||
|
|
||||
|
// nome del file che creeremo |
||||
|
$filename=$_GET['db']."_".date("d-m-Y").".xls"; |
||||
|
|
||||
|
header ("Content-Type: application/vnd.ms-excel"); |
||||
|
|
||||
|
header ("Content-Disposition: attachment; filename=$filename"); |
||||
|
|
||||
|
|
||||
|
?> |
||||
|
|
||||
|
|
||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
||||
|
<html lang=it><head> |
||||
|
<title><?php echo $filename;?></title></head> |
||||
|
<body> |
||||
|
<table> |
||||
|
|
||||
|
<?php |
||||
|
|
||||
|
switch($_GET['db']){ |
||||
|
case "board": |
||||
|
$fields=array("last_name","first_name","address","zip_code","city","province"); |
||||
|
$order="last_name"; |
||||
|
break; |
||||
|
case "farmacie": |
||||
|
$fields=array("farmacia","via","comune"); |
||||
|
$order="farmacia"; |
||||
|
break; |
||||
|
case "parafarmacie": |
||||
|
$fields=array("parafarmacia","via","comune"); |
||||
|
$order="parafarmacia"; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
echo "<tr><td>"; |
||||
|
echo strtoupper(implode("</td><td>",$fields)); |
||||
|
echo "</td></tr>\n"; |
||||
|
|
||||
|
$q=mysqli_query($conn,"SELECT ".implode(",",$fields)." FROM ".$_GET['db']." ORDER BY $order"); |
||||
|
while($r=mysqli_fetch_array($q)){ |
||||
|
echo "<tr>"; |
||||
|
for($i=0;$i<count($fields);$i++){ |
||||
|
echo "<td>".$r[$fields[$i]]."</td>"; |
||||
|
} |
||||
|
echo "</tr>\n"; |
||||
|
} |
||||
|
|
||||
|
?> |
||||
|
|
||||
|
</table> |
||||
|
</body></html> |
Loading…
Reference in new issue