ลองแก้เองดูแล้ว ตามที่ post กันไว้ แต่ไม่ได้ผล ช่วยดูที่คับ
Code (PHP)
<?php
require_once("lib/phpchartdir.php");
require_once("configuration/connectiondb.inc.php");
$sid = 424;
$qid = 1;
$data = array();
$labels= array();
$sql = " SELECT survey_id, question_id, answer_id FROM analysis_of_response ";
$sql .= " WHERE survey_id = '$sid' AND question_id = '$qid' GROUP BY answer_id ";
$obj = mysql_query($sql);
$sql2 = " SELECT answer_text FROM survey_answers ";
$sql2 .= " WHERE survey_id = '$sid' AND question_id = '$qid' ";
$obj2 = mysql_query($sql2);
$sql3 = " SELECT question_details FROM questions ";
$sql3 .= " WHERE survey_id = '$sid' ";
$obj3 = mysql_query($sql3);
$rw3 = mysql_fetch_array($obj3);
$title = iconv('TIS-620','UTF-8',$rw3['question_details']); // SET กราฟเป็น ภาษาไทย
$i = 0;
$j = 0;
while($rw = mysql_fetch_array($obj)) {
$data[$i] = $rw['answer_id'];
$i++;
}
while($rw2 = mysql_fetch_array($obj2)){
$labels[$j] = $rw2['answer_text'];
$j++;
}
# Create a PieChart object of size 360 x 300 pixels
$c = new PieChart(360, 300);
# Set the center of the pie at (180, 140) and the radius to 100 pixels
$c->setPieSize(180, 140, 100);
# Add a title to the pie chart
$c->addTitle($title);
# Draw the pie in 3D
$c->set3D();
# Set the pie data and the pie labels
$c->setData($data, $labels);
# Explode the 1st sector (index = 0)
$c->setExplode(0);
# Output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>