Location: PHPKode > projects > ERPSOD > erpsod/exp_sod.php
<?PHP
include_once("config.php");
$ok=role_check();
if (!$ok){
	header("Location: login.php"); 
}
$sql=" select taskname,mitigated,sodid,reason,sodform from erptask,tasksod where tasksod.taskid=erptask.taskid order by taskname";
$result = mysql_query($sql) or die(mysql_error());
// Put the name of all fields
$out  = "Taskname";
$out .= ",";
$out .= "Sodname";
$out .= ",";
$out .= "Reason";
$out .= ",";
$out .= "Mitigated";
$out .= ",";
$out .= "SOD-Form";
$out .="\n";
// Add all values in the table
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
	$sql1="select taskname from erptask where taskid=$row[2]";
	$result1 = mysql_query($sql1) or die(mysql_error());
	$row1 = mysql_fetch_array($result1, MYSQL_NUM) ;
	$out .= trim("$row[0]" );
	$out .= ",";
	$out .= trim("$row1[0]");
	$out .= ",";
	$out .= "$row[3]";	
	$out .= ",";
	$out .= "$row[1]";	
	$out .= ",";
	$out .= "$row[4]";	
	$out .="\n";
}
// Output to browser
header('Content-type: text/richtext');
header("Content-Disposition: attachment; filename=sod_exported.csv");
echo $out;
Return current item: ERPSOD