Date selectors for CSV download from SQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dilby
Forum Newbie
Posts: 6
Joined: Tue Nov 09, 2010 11:08 am

Date selectors for CSV download from SQL

Post by dilby »

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!

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;

Post Reply