我正在将我的MySQL数据库数据解析为融合图表代码&画一个饼图...但不幸的是有些字符不显示..请帮助恢复这个问题... 这是我的代码:
<?php
include("FusionCharts/FusionCharts.php");
include("special_db_connect.php");
?>
<HTML>
<HEAD>
<TITLE>
Exam Result Analysis
</TITLE>
<?php
?>
<script LANGUAGE="Javascript" SRC="FusionCharts/FusionCharts.js"></SCRIPT>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.text{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</HEAD>
<BODY>
<CENTER>
<?php
// Connect to the DB
$link = connectToDB();
//Generate the chart element
$strXML = "<chart caption='Academic year 2010/2011 results' subCaption='By Grades' pieSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix=' Students'>";
// Fetch all factory records
$strQuery = "SELECT grade, COUNT(*) 'No_Of_grades' FROM std_results WHERE course_code ='CSC113A' GROUP BY grade";
$result = mysql_query($strQuery) or die(mysql_error());
//Iterate through each factory
if ($result) {
while($ors = mysql_fetch_array($result)) {
//Generate <set label='..' value='..' />
$strXML .= "<set label='" . $ors['grade'] . "' value='" . $ors['No_Of_grades'] . "' />";
}
}
//Finally, close <chart> element
$strXML .= "</chart>";
//Create the chart - Pie 3D Chart with data from $strXML
echo renderChart("FusionCharts/Pie3D.swf", "", $strXML, "Results", 600, 300, false, false);
echo "</br></br>";
mysql_close($link);
?>
</CENTER>
</BODY>
</HTML>
输出饼图
......这高于我的代码
{$strQuery = "SELECT grade, COUNT(*) 'No_Of_grades' FROM std_results WHERE course_code ='CSC113A' GROUP BY grade";}
:phpmyadmin中此代码的结果:
实际上这个表值将解析为饼图。你可以在等级列A +,C +值中看到...问题是那些字符串不在饼图中显示。{请访问上面的饼图图像}。实际上A +&amp; C +显示没有'+'字符。{但' - ',C-,A-字符显示} ..这对我来说是一个问题..我怎么能解决这个问题... {提醒上面的代码工作正常..没有关于这个问题的唯一问题是没有显示'+'字符。} **
答案 0 :(得分:0)
尝试使用%2B编码符号+:
$strXML .= "<set label='" . str_replace('+', '%2B', $ors['grade']) . "' value='" . $ors['No_Of_grades'] . "' />";