<?php
header("Content-type: text/xml" );
$host = "localhost";
$user = "root";
$pass = "password" ;
$database = "database";
$linkID = mysql_connect($host, $user , $pass) or die("Could not connect to host.");
mysql_select_db ($database, $linkID) or die("Could not find database." );
$query = "SELECT accounts.name AS \"Client\", accounts_cstm.remaininglicenses_c AS \"RemainingLicenses\", accounts_cstm.usedlicenses_c AS \"UsedLicenses\", accounts_cstm.studentsenrolled_c AS \"StudentsEnrolled\"
FROM accounts_cstm INNER JOIN accounts ON accounts_cstm.id_c = accounts.id
WHERE (((accounts_cstm.remaininglicenses_c)>\"0\") AND ((accounts.deleted)=0));";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<chart caption=\"License Usage Report\" subcaption=\"by Client\" palette=\"1\">";
$xml_output .= "\t<categories>";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t\t<category label=\"" . $row['Client'] . "\" />";
}
$xml_output .= "\t</categories>";
//GET LICENSES REMAINING
$query = "SELECT accounts.name AS \"Client\", accounts_cstm.remaininglicenses_c AS \"RemainingLicenses\", accounts_cstm.usedlicenses_c AS \"UsedLicenses\", accounts_cstm.studentsenrolled_c AS \"StudentsEnrolled\"
FROM accounts_cstm INNER JOIN accounts ON accounts_cstm.id_c = accounts.id
WHERE (((accounts_cstm.remaininglicenses_c)>\"0\") AND ((accounts.deleted)=0));";
$resultID2 = mysql_query($query, $linkID) or die("Data not found.");
$xml_output .= "\t<dataset SeriesName=\"Licenses Remaining\">";
for($y = 0 ; $y < mysql_num_rows($resultID2) ; $y++){
$rowy = mysql_fetch_assoc($resultID2);
$xml_output .= "\t\t<set value=\"" . $rowy['RemainingLicenses'] . "\" />";
}
$xml_output .= "\t</dataset>";
//GET USED LICENSES
$query = "SELECT accounts.name AS \"Client\", accounts_cstm.remaininglicenses_c AS \"RemainingLicenses\", accounts_cstm.usedlicenses_c AS \"UsedLicenses\", accounts_cstm.studentsenrolled_c AS \"StudentsEnrolled\"
FROM accounts_cstm INNER JOIN accounts ON accounts_cstm.id_c = accounts.id
WHERE (((accounts_cstm.remaininglicenses_c)>\"0\") AND ((accounts.deleted)=0));";
$resultID2 = mysql_query($query, $linkID) or die("Data not found.");
$xml_output .= "\t<dataset SeriesName=\"Used Licenses\">";
for($y = 0 ; $y < mysql_num_rows($resultID2) ; $y++){
$rowy = mysql_fetch_assoc($resultID2);
$xml_output .= "\t\t<set value=\"" . $rowy['UsedLicenses'] . "\" />";
}
$xml_output .= "\t</dataset>";
//GET STUDENTS ENROLLED
$query = "SELECT accounts.name AS \"Client\", accounts_cstm.remaininglicenses_c AS \"RemainingLicenses\", accounts_cstm.usedlicenses_c AS \"UsedLicenses\", accounts_cstm.studentsenrolled_c AS \"StudentsEnrolled\"
FROM accounts_cstm INNER JOIN accounts ON accounts_cstm.id_c = accounts.id
WHERE (((accounts_cstm.remaininglicenses_c)>\"0\") AND ((accounts.deleted)=0));";
$resultID2 = mysql_query($query, $linkID) or die("Data not found.");
$xml_output .= "\t<dataset SeriesName=\"Students Enrolled\">";
for($y = 0 ; $y < mysql_num_rows($resultID2) ; $y++){
$rowy = mysql_fetch_assoc($resultID2);
$xml_output .= "\t\t<set value=\"" . $rowy['StudentsEnrolled'] . "\" />";
}
$xml_output .= "\t</dataset>";
$xml_output .= "\t</chart>";
echo $xml_output;
?>