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.
<?
// set up the database access
$my_serverName = "localhost";
$my_userName = "myprivateusername";
$my_password = "myprivatepassword";
$my_database = "mydatabasename";
// open a connection to my database
$link = @mysql_connect($my_serverName, $my_userName, $my_password);
mysql_select_db($my_database);
// perform the select from the table
$result = mysql_query("SELECT * FROM mytable");
// set up the CSV headers for the output string
$my_data = '"ID","Name","Phone number"';
$my_data .= "\n";
// loop through our dataset and append each row to the CSV output string
while ($row = mysql_fetch_array($result))
{
$my_data .= $row["id"] . ',';
$my_data .= '"' . $row["name"] . '",';
$my_data .= '"' . $row["telephone"] . '",';
$my_data .= "\n";
}
// close the database connection
mysql_close($link);
// define the output filename (should the user want to save the file)
$output_file = 'MyExportedData.csv';
// turn off zlib compression
if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off');
// send all these headers to the browser first
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Content-Transfer-Encoding: none');
header('Content-Type: application/octetstream; name="' . $output_file . '"');
header('Content-Type: application/octet-stream; name="' . $output_file . '"');
header('Content-Disposition: attachment; filename="' . $output_file . '"');
// send the CSV data string to the browser
echo $my_data;
// done
exit();
?>