<html><head><title>Mark Test</title></head><body>
<?php
//print_r($_POST);
if (!$_POST || $_POST == '')
{
$t=time();
$dateToUse= date('Y-m-d');
}
else
{
//change the month to numbers
$month_arr=array("01"=>"JAN","02"=>"FEB","03"=>"MAR","04"=>"APR","05"=>"MAY","06"=>"JUN","07"=>"JUL","08"=>"AUG","09"=>"SEP","10"=>"OCT","11"=>"NOV", "12"=>"DEC");
$datum1 = $_POST;
$daydate = $datum1.$datum1;
$monthdatest = $datum1.$datum1;
$monthdate=$month_arr;
$yeardate = $datum1.$datum1.$datum1.$datum1;
//error check for date
if(!checkdate($monthdatest,$daydate,$yeardate)){$flag=FALSE;}
if ($flag === FALSE){echo "<p><font color='red'><b>The date range entered is invalid";die(0);}
$dateToUse = "$yeardate-$monthdatest-$daydate";
}
//start DB stuff
$db_host = 'localhost';
$db_user = 'user';
$db_pwd = 'passwordx';
$database = 'neotechc_ostt1';
$table = 'ost_ticket';
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");
//query
//echo "SELECT * FROM {$table} WHERE created LIKE '$dateToUse%' AND costentity = 'TUT' AND campus = 'Nelspruit'";
//echo "<br>";
//echo "<br>";
$result = mysql_query("SELECT * FROM {$table} WHERE created LIKE '$dateToUse%' AND costentity = 'TUT'");
if (!$result) {
die("Query to show fields from table failed");
}
$fields_num = mysql_num_fields($result);
//echo $fields_num;
//echo "<BR>";
$field = mysql_fetch_field($result);
//end DB stuff
/**
* start the xml file content here
*/
$xml_output = "<chart palette='4' decimals='0' enableSmartLabels='1' enableRotation='0' bgColor='99CCFF,FFFFFF' bgAlpha='40,100' bgRatio='0,100' bgAngle='360' showBorder='1' startingAngle='70' >\n";
while($row = mysql_fetch_row($result))
{
//to view the filds avalible
//print_r($row);
//echo "<br><br>";
//get the information from the array to display in the file
$campus = $row;
$created = $row;
$cost = $row;
$xml_output .= "<set label='$campus' value='$cost' />\n";
}
$xml_output .= "</chart>\n";
/**
* end the xml file content here
*/
/**
* start the xml file create here
*/
//echo $xml_output;
//get the date for the file name
$t=time();
$Day= date('Y-m-d');
//what file to use
$filename = "test$Day.xml";
//Lets remove the existing file
//if(file_exists($filename))
//{
// unlink($filename);
//}
//will NOT overright the file
//create new file
$handle = fopen($filename, "wr");;
//write the xml to the file
fwrite($handle, $xml_output);
//close the file
fclose($handle);
/**
* end the xml file create here
*/
mysql_free_result($result);
?>
</body></html>