






























Questions? Email us:
sales@haneng.com
|
|
HanengCharts & PHP
HanengCharts Whitepaper


Introduction
HanengCharts is Java applets that you use with your website by supplying
the parameters (the values and labels) through HTML PARAM tags. This allows
any technology that can generate HTML to work dynamically with HanengCharts.
This whitepaper will give you some sample scripts and explanations on how
you can use HanengCharts and PHP to generate charts based on
data stored in a database.


PHP and MySQL
<HTML>
<BODY>
<CENTER>
<APPLET CODE="HanengCharts.class" ARCHIVE="HanengCharts3.jar" WIDTH=460 HEIGHT=260>
<PARAM NAME="LicenseKey" VALUE="30DAYDEMO-JVsta5CFaZYyN9">
<PARAM NAME="ChartType" VALUE="pie">
<?php
$conn = mysql_Connect("localhost", "msqluser", "mysqlpass");
if($conn)
{
$SQL_string="select * from Chart";
$resultset = mysql_db_query("HanengCharts", $SQL_string, $conn);
if($resultset)
{
while($th_row=mysql_fetch_array($resultset))
{
echo "<PARAM NAME=\"".$th_row["ParameterName"]."\" VALUE=\"".$th_row["Value"]."\">\n";
}
}
}
?>
</APPLET>
</CENTER>
</BODY>
</HTML>
This assumes that you want to use a MySQL database (It should be easy to change it to work
with another database) and it assumes that the database is on the localhost(not really
necessary) and that the username/password to access the database is
mysqluser/mysqlpass. It further assumes that the data is stored in the database "HanengCharts"
in the table "Chart" and that "Chart" has the fields "ParameterName" and "Value":
Table: Chart
| ParameterName |
Value |
| text_1 |
Salesteam 1 |
| text_2 |
Salesteam 2 |
| text_3 |
Salesteam 3 |
| text_4 |
Salesteam 4 |
| text_5 |
Salesteam 5 |
| value_1 |
70 |
| value_2 |
200 |
| value_3 |
140 |
| value_4 |
40 |
| value_5 |
30 |
The result will look like this:
Back to the Developers Zone
|
|