You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.1 KiB

7 years ago
<?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;
7 years ago
case "pharmacy":
$fields=array("pharmacy","address","city");
$order="pharmacy";
7 years ago
break;
7 years ago
case "parapharmacy":
$fields=array("parapharmacy","address","city");
$order="parapharmacy";
7 years ago
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>