Trouble is, it's only putting "email" into field A1 and then nothing else. Anyone know why?
Code: Select all
<?php
$cookietype = $_COOKIE['type'];
$id=$_request['id'];
if ($cookietype == "admin") {
include "dbconn.php";
$csv_output = '"email"';
$csv_output .= "\015\012";
$result = mysql_query("select * from diary WHERE raceid = '$id'");
while($row = mysql_fetch_object($result))
{
$users = mysql_query("select * from admin WHERE id = '$row->userid'");
while($user = mysql_fetch_array($users))
{
$csv_output .= '"'.$user[email].'"';
$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=document_" . 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=index.php?page=a_login&menu=a_admin'>";
}
?>