Done is a yes a no... It does work, But I would like it different.
here is my Export.php
<?php
//Database connection
$host = 'localhost';
$user = '****l';
$pass = '****';
$db = '****';
$table = 'January_Whirl';
$file = 'export';
// Enter the fields you want to include in the export.
$fields = "patron_loading_max, patron_loading_24hr, water_clearity__clear, water_clearity__turbid, water_temp, psi, gpm, drain_back, chlorine_am1, chlorine_am2, chlorine_pm1, chlorine_pm2, ph_am1, ph_am2, ph_pm1, ph_pm2, combined_chl, alkalinity, chemicals_add, chemicals_qty, super_oxidation";
//Enter the column names you want to exclude. Name must not be in Fields above.
$columns = "Dayid";
$filename = $file."_".date("Y-m-d");
$link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
mysql_select_db($db) or die("Can not connect.");
$result = mysql_query("SHOW COLUMNS FROM ".$table." WHERE Field NOT IN ('$columns')");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
//$csv_output .= $row['Field'].","; //Uncomment to print column names
$i++;
}
}
$csv_output .= "\n, \n, \n, \n, \n, \n"; //Extra rows "\n" to import at row 7 in excel
$values = mysql_query("SELECT $fields FROM ".$table."");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j].",";
}
$csv_output .= "\n";
}
$filename = $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
?>
As of now what I would like, Shift the data over in the CSV so i would line up with column C (Third column) in excell. And/or Instead of creating a csv put the data directly into my custom excel file when this export file is ran.
Can that be done?