I have an older PHP app that I am trying to figure out why I cannot export to CSV anymore.
On the page where sql data is displayed on the page the following link is displayed for exporting to CSV:
<p class="content_text"><strong><a href="export.php?tablename=PrivateActs109">Export to Excel</a></strong></p>
And then the entirety of the export.php
file:
<?php /* ########## Connect to Database ########## */
require_once('../Connections/dbConnect_acts.php');
mysql_select_db($database_dbConnect, $dbConnect) or die ("no luck") ;
// Export to CSV
require '../includes/exportcsv.inc.php';
$table=$tablename; // this is the tablename that you want to export to csv from mysql.
$sql_query = "SELECT `ChapterNumber`, `Subject`, `Abstract` , `BillNumber` FROM $tablename ";
exportMysqlToCsv($table,$sql_query);
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header("Content-Length: " . strlen($out));
// Output to browser with appropriate mime type, you choose ;)
//header("Content-type: text/x-csv");
//header("Content-type: text/csv");
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=$filename");
?>
Looking for direction since I am still pretty new to PHP.