But it's producing a ton of these:
[text]Notice: Use of undefined constant firstname - assumed 'firstname' in C:\xampp\phpMyAdmin\site\csv_NEWrequestssent.php on line 19[/text]
Code: Select all
<?php
session_start();
if (isset($_SESSION["loggedin"]))
{
$usertype = $_SESSION["usertype"];
$id = isset($_GET['id']) ? $_GET['id'] : null;
if ($usertype == "admin" || $usertype == "moderator") {
include "dbconn.php";
$csv_output = '"Firstname","Lastname","House","Street","Town","County","Postcode","Product","Date Requested","Date Sent"';
$csv_output .= "\015\012";
$result = mysql_query("SELECT * FROM samples WHERE dateposted IS NOT NULL ORDER BY dateposted");
while($row = mysql_fetch_array($result))
{
$resultu = mysql_query("SELECT * FROM admin WHERE id = '$row[userid]'");
while($rowu = mysql_fetch_array($resultu))
{
$csv_output .= '"'.$rowu[firstname].'","'.$rowu[lastname].'","'.$rowu[address1].'","'.$rowu[address2].'","'.$rowu[town].'","'.$rowu[county].'","'.$rowu[postcode].'","'.$row[prodname].'","'.$row[dateadded].'","'.$row[dateposted].'"';
$csv_output .= "\015\012";
}
}
//You cannot have the breaks in the same feed as the content.
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv; filename=RequestsSent_" . date("Ymd") .".csv");
print $csv_output;
exit;
mysql_close($sqlconn);
echo "Extract in progress - close page when completed.";
}}
else
{
echo "<meta http-equiv='Refresh' content='0 ;URL=/'>";
}
?>