<?php
$host="localhost";
$user="";
$pass="";
$dbname="";
$conn=mysql_connect($host,$user,$pass) or die (mysql_error());
mysql_select_db($dbname) or die (mysql_error());
mysql_query("SET NAMES UTF8");
//function random
function rgb2hex($r, $g, $b, $uppercase=false, $shorten=false)
{
// The output
$out = "";
// If shorten should be attempted, determine if it is even possible
if ($shorten && ($r + $g + $b) % 17 !== 0) $shorten = false;
// Red, green and blue as color
foreach (array($r, $g, $b) as $c)
{
// The HEX equivalent
$hex = base_convert($c, 10, 16);
// If it should be shortened, and if it is possible, then
// only grab the first HEX character
if ($shorten) $out .= $hex[0];
// Otherwise add the full HEX value (if the decimal color
// is below 16 then we have to prepend a 0 to it)
else $out .= ($c < 16) ? ("0".$hex) : $hex;
}
// Package and away we go!
return $uppercase ? strtoupper($out) : $out;
}
//โค๊ด random สีกราฟ
echo "<graph numdivlines='4' lineThickness='3' showValues='0' numVDivLines='10' formatNumberScale='2' rotateNames='1' decimalPrecision='2' anchorRadius='2' anchorBgAlpha='0' numberPrefix='' divLineAlpha='30' showAlternateHGridColor='1' yAxisMinValue='800000' shadowAlpha='50' >";
echo "<categories>";
// เดือน 12 เดือน ----->>
//$aa="2014";
$aa=$_GET["aa2"];
$strQueryData = ".......";
$charset = "SET NAMES UTF8";
mysql_query($charset);
$resultData = mysql_query($strQueryData) or die(mysql_error());
while($arr=mysql_fetch_array($resultData)){
echo "<category Name='".$arr[Mydate]."'/>";
}
echo "</categories>";
$strQueryData_new = "SELECT ......";
$charset = "SET NAMES UTF8";
mysql_query($charset);
$resultData_new = mysql_query($strQueryData_new) or die(mysql_error());
while($arr_new=mysql_fetch_array($resultData_new)){
$name_ =$arr_new['V_TOTAL2_'];
echo "<dataset seriesName='".$arr_new[V_TOTAL2_]."' color='".rgb2hex(rand(0, 255), rand(0, 255), rand(0, 255), true)."' anchorBorderColor='F6BD0F' anchorRadius='4'>";
// ผลรวม sum model ทุก เดือน --------------->>
$strQueryData_new_1 = "SELECT.......";
$charset = "SET NAMES UTF8";
mysql_query($charset);
$resultData_new_1 = mysql_query($strQueryData_new_1) or die(mysql_error());
while($arr_new_1=mysql_fetch_array($resultData_new_1)){
$Mydate=$arr_new_1['Mydate'];
$V_TOTAL2_=$arr_new_1['V_TOTAL2_'];
$V_TOTAL_new=$arr_new_1['V_TOTAL_new'];
echo "<set value='".$arr_new_1['V_TOTAL_new'] / 10000 ."'/>";
}
echo "</dataset>";
}
echo "</graph>";
?>