<?php
include('/var/www/html/uclit/protected/common/login/check.php'); 
include('/var/www/html/uclit/protected/connections/db_arlstats.php');

$db = @mysql_select_db($database_arlstats, $arlConn) or die ("Unable to select Current Stats database.");

$query_status = $_POST['current_status'];
$saveWord = $_POST['saveWord'];

$Recordset1 = mysql_query($query_status, $arlConn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

//Export to Excel Server Behavior
if (isset($_POST['saveWord'])&&($_POST['saveWord']=="2")){
$output=" ";
$include_hdr="";
if($include_hdr=="1"){
	$totalColumns_libitdb=mysql_num_fields($Recordset1);
	for ($x=0; $x<$totalColumns_libitdb; $x++) {
		if($x==$totalColumns_libitdb-1){$comma="";}else{$comma=",";}
		$output = $output.(ereg_replace("_", " ",mysql_field_name($Recordset1, $x))).$comma;
	}
	$output = $output."\r\n";
}

do{$fixcomma=array();
    foreach($row_Recordset1 as $r){array_push($fixcomma,ereg_replace(",","¸",$r));}
    $line = join(",",$fixcomma);
    $line=ereg_replace("\r\n", " ",$line);
    $line = "$line\n";
    $output=$output.$line;}while($row_Recordset1 = mysql_fetch_assoc($Recordset1));
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=report.csv");
header("Content-Type: application/force-download");
header("Cache-Control: post-check=0, pre-check=0", false);
echo $output;
die();
}

include('/var/www/html/uclit/protected/common/css_login/css_head2.php');
//export to excel
echo "Hello:$query_status";
echo "Hello2: $saveWord";

?>
Select an application from the menu on the left.
<br>
<br>
<p>&nbsp;</p>
<br>
<p>&nbsp;</p><br>
<p>&nbsp;</p><br>
<p>&nbsp;</p><br>
<p>&nbsp;</p>

<?php


require ('/var/www/html/uclit/protected/common/css_foot2.php');
?>
<?php
mysql_free_result($Recordset1);

mysql_free_result($libitdb);
?>
