Date selectors for CSV download from SQL
Posted: Fri Dec 10, 2010 8:33 am
Hi all -
I am trying to modify some code that downloads users details from database. At the moment you download a csv file which pulls the data from a 'clients' table. I need to be able to add a way of selecting from and to dates (preferably using two calendar selectors) that the user signed up. Currently there is a 'date_added' column in the table (timestamp.)
The code is below that I found there at the moment. Is anyone able to help? Thanks!
I am trying to modify some code that downloads users details from database. At the moment you download a csv file which pulls the data from a 'clients' table. I need to be able to add a way of selecting from and to dates (preferably using two calendar selectors) that the user signed up. Currently there is a 'date_added' column in the table (timestamp.)
The code is below that I found there at the moment. Is anyone able to help? Thanks!
Code: Select all
require_once('../libs/common.php');
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"clients_".date('d-m-Y').".csv\"");
$link = connect();
$getAllClients = mysql_query("SELECT * FROM clients ORDER BY created DESC",$link);
$out = '';
while ($row = mysql_fetch_assoc($getAllClients)){
$out .= $row['name'].','.$row['lastname'].','.$row['email'].','.$row['postcode'].','.$row['created']."\r\n";
}
echo $out;