$count_rs1=mysql_query("SELECT COUNT(polls_id) AS Total1 FROM polls WHERE polls_id LIKE'1' ");
while($row_count1=mysql_fetch_assoc($count_rs1)) {
echo $row_count1['Total1']*100/($row_count1['Total1']) ;
/*mysql_select_db($database_moneydb, $moneydb);
$query_sum = "SELECT sum(payamount) as sumpay,paydate FROM dailypay WHERE 1 $paycond and createby = '1' GROUP BY paydate";
//echo $query_sum;
$sum = mysql_query($query_sum, $moneydb) or die(mysql_error());
while ($row_sum = mysql_fetch_assoc($sum)){
$datay[substr($row_sum['paydate'],8)-1] = $row_sum['sumpay'] ;
}
*/
$conn=mysql_connect("localhost","root","55");
$dbname=mysql_select_db("polls");
//LIKE 1 ใช่
$count_rs1=mysql_query("SELECT COUNT(polls_id) AS Total1 FROM polls WHERE polls_id LIKE'1'");
while($row_count1=mysql_fetch_assoc($count_rs1)) {
//$datay2[substr($row_count1['Total1'],8)-1] ;
//$datay = array[];
//$datay[]=$row_count1['Total1'];
$datay[]=$row_count1['Total1'];
}
//LIKE ไม่ใช่
$count_rs2=mysql_query("SELECT COUNT(polls_id) AS Total2 FROM polls WHERE polls_id LIKE'2'");
while($row_count2=mysql_fetch_assoc($count_rs2)) {
$datay2[]=$row_count2['Total2'];
}
//LIKE เฉยๆ
$count_rs3=mysql_query("SELECT COUNT(polls_id) AS Total3 FROM polls WHERE polls_id LIKE'3'");
while($row_count3=mysql_fetch_assoc($count_rs3)) {
$datay3[]=$row_count3['Total3'];
}
//$datay = array(12,8);//
/*$query_sum = "SELECT sum(payamount) as sumpay,paydate FROM dailypay WHERE 1 $paycond and createby = '2' GROUP BY paydate";
$sum = mysql_query($query_sum, $moneydb) or die(mysql_error());
while ($row_sum = mysql_fetch_assoc($sum)){
$datay2[substr($row_sum['paydate'],8)-1] = $row_sum['sumpay'] ;
}
*/
//$datay2 = array(12,8);//
$graphtitle = "test ".$monthname[intval($currentmonth)];
?>
<?php
include ("graph/jpgraph.php");
include ("graph/jpgraph_bar.php");
//print_r($data2y);
// Create the graph. These two calls are always required
$graph = new Graph(1048,550); // กำหนดขนาด
$graph->SetScale("textlin");
$graph->legend->SetFont(FF_ANGSA,FS_BOLD,16); //SetFont(FF_FONT1,FS_BOLD);//
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillColor("orange");
$b1plot->value->Show();
$b1plot->SetLegend('ชอบ');
$b2plot = new BarPlot($data2y);
$b2plot->SetFillColor("blue");
$b2plot->value->Show();
$b2plot->SetLegend('ไม่ชอบ');
$b3plot = new BarPlot($data3y);
$b3plot->SetFillColor("orange");
$b3plot->value->Show();
$b3plot->SetLegend('เฉยๆ');
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot,$b2plot,$b3plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$graph->title->SetFont(FF_ANGSA,FS_BOLD,20); // กำหนด font ไทย
$graph->title->Set("$graphtitle");
//$graph->title->Set("CSIM with popup windows");
$graph->xaxis->title->SetFont(FF_ANGSA,FS_NORMAL,12); // กำหนด font ไทย
$graph->xaxis->title->Set("");
$graph->yaxis->title->SetFont(FF_ANGSA,FS_NORMAL,12); // กำหนด font ไทย
$graph->yaxis->title->Set("จำนวน (บาท)");