Php > Graphics
Php Script for RChart
Php Script for RChart The following example will create an area chart (it is very similar to the example Chart2.htm). It will retrieve the data from an MSAccess database that contains a table called "salesMonth". This table has three fields: "Products" (integer), "Services" (integer) and "salesMonth" (date), which contains the sales for several months. The example will display the sales of the last 6 months. It will create a HTML page that contains the applet. Most of the parameters of the applet are constant, however the date labels and the sales data is retrieved from the DB.
$labels=""; $values2=""; $values1=""; $i=1; /* connect to database open db using a System ODBC data source called "Data" */ $odbcid = odbc_connect ("data", "", "", ""); /* get sales data, execute SQL*/ $resultid = odbc_exec ($odbcid, "Select * from SalesMonth Order by salesMonth DESC") ; /* iterate on sales data, up to 6 rows */ while (($i <= 6) and (odbc_fetch_row($resultid))) { /* concatenate | separator */ if ($i>1) { $values1= "|" . $values1; $values2= "|" . $values2; $labels= "|" . $labels; } /* concatenate value */ $values1= odbc_result ($resultid, "Services") . $values1; $values2= odbc_result ($resultid, "Product") . $values2; $labels= odbc_result ($resultid, "salesMonth") . $labels; $i=$i+1; /* next record */ odbc_fetch_row($resultid); } /* echo values for serie 1 */ echo "
"; /* echo values for serie 2 */ echo "
"; /* echo values for labels */ echo "
"; /* close result */ odbc_free_result($resultid); /* close connection */ odbc_close($odbcid); ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage