1

我正在将我的 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+ & C+ 显示没有 '+' 字符。{但 '-',C-,A- 字符显示}..这对我来说是个问题..我该如何解决这个问题...{提醒上面的代码运行良好..否唯一的问题是不显示“+”字符。}**

4

1 回答 1

0

尝试使用 %2B 对符号 + 进行编码:

$strXML .= "<set label='" . str_replace('+', '%2B', $ors['grade']) . "' value='" . $ors['No_Of_grades'] . "' />";
于 2012-12-08T17:17:06.377 回答