I've got a simple table that is storing unique IDs tied to a download. What I'm trying to do is generate a CSV of the most recent IDs created. Each time keys are generated (anywhere from 1 to 100 keys at a time), a UNIX timestamp is stored with those keys.
I have the CSV file generating just fine, but I can't get the MAX function to work properly. My report generator is below:
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=codes.csv');
// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');
// output the column headings
fputcsv($output, array('Unique Codes'));
// fetch the data
/** database username and pass removed **/
$rows = mysql_query('SELECT uniqueid FROM downloadkeys');
// loop over the rows, outputting them
while ($row = mysql_fetch_assoc($rows)) fputcsv($output, $row);