<?PHP
include_once("config.php");
$ok=role_check();
if (!$ok){
header("Location: login.php");
}
$sql=" select taskname,taskdesc from erptask order by taskname";
$result = mysql_query($sql) or die(mysql_error());
// Put the name of all fields
$out = "Taskname";
$out .= ",";
$out .= "Taskdesc";
$out .="\n";
// Add all values in the table
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$out .= trim("$row[0]" );
$out .= ",";
$out .= trim("$row[1]");
$out .="\n";
}
// Output to browser
header('Content-type: text/richtext');
header("Content-Disposition: attachment; filename=tasks_exported.csv");
echo $out;