Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?
//configure the database here, or pass it along with $sql (the query) and $query (the value used to name the file).
$db="database";
// I use a config.inc.php with the databse connection details, include one here if required
//require('config.inc.php');
if(!isset($sql)){
echo "No Query";
exit;
}else{
$sql=stripslashes($sql);
$file=$query.".csv";
}
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment;filename=".$file );
header('Pragma: no-cache');
header('Expires: 0');
mysql_select_db($db,$connection);
$result = mysql_query($sql,$connection);
if($result){
$columns=@mysql_num_fields($result);
for ($i = 0; $i < mysql_num_fields($result); $i++) {
print "\"".mysql_field_name($result,$i)."\",";
}
echo "\n";
while ($myrow = mysql_fetch_array($result)){
for ($i = 0; $i < ($columns); $i++) {
echo "\"".$myrow[$i]."\",";
}
echo "\n";
}
}else{
echo "No results";
}
?>
<table border="1">
<tr>
<td>column 1</td>
<td>column 2</td>
</tr>
</table>