I am trying to send some data to a 'states.csv'. It sends over part of the data, but it also sends over a lot of html! I really don't understand. It's driving me crazy! Thanks. Here's my code.
<?php
if($nowdate!='')
{
header("Content-type: application/data");
header("Content-Disposition: attachment; filename=states.csv");
}
require("$DOCUMENT_ROOT/includes/var.php");
@qdbconn();
if($nowdate != '')
{
$qry = mysql_query("SELECT Name, SUM(Tot) as Tot FROM TestTime WHERE Dat BETWEEN date_format('$nowdate','%Y-%m-%d') AND date_format('$enddate','%Y-%m-%d') GROUP BY Name ORDER BY Name");
WHILE($row = mysql_fetch_array($qry))
{
// Pull out your variables and manipulate them.
$name = $row['Name'];
$startTime = $row['Tot']; //probably put Tot here
$difference = $startTime;
$nhours = floor($difference / 3600); // One hour has 3600 seconds
$nseconds = $difference % 3600;
$nminutes = round($nseconds / 60); // One minute has 60 seconds, duh!
$nseconds = $nseconds % 60;
// echo $name;
print("<HTML><CENTER><FONT SIZE=+0><b>$name $name </FONT></b> - <FONT SIZE=+0><i><b>$nhours </FONT></i></b><FONT SIZE=+0> hour(s) </FONT><FONT SIZE=+0><i><b>$nminutes </FONT></i></b><FONT SIZE=+0> minute(s)<FONT></CENTER></HTML>");
}
//exit();
}
@printHead();
print("<H3 CLASS=\"pgtitle\" ALIGN=\"right\">Clock Totals</H3>");
//print("<H3 CLASS=\"pgtitle\" ALIGN=\"right\"><!-- the blue Bar document title --></H3><br><br>");
print("<title>Untitled Document</title>");
print("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
print("<form action=\"try.php\" method=\"post\" name=\"listing\" id=\"listing\">");
print("<table><TR><TD height=\"21\"> </TD><TD height=\"21\">Start Date in YYYY-MM-DD:<input type=\"text\" name=\"nowdate\"> </TD></TR></table>");
print("<table><TR><TD height=\"21\"> </TD><TD height=\"21\">End Date in YYYY-MM-DD:<input type=\"text\" name=\"enddate\"></TD></TR></table>");
print("<input type=\"Submit\"name=\"Total1\" value=\"Total1\">");
print("</form>");
@printFoot();
?>