/* ---------------------------------------------------------------- */ /* The following script is a sample script designed to demonstrate */ /* a method for creating real-time dynamic pie charts from data */ /* held within databases. */ /* */ /* This sample connects to a MySQL database and reads data from */ /* a table "SalesBar". It then formats the data for use by the */ /* Bar Graph Applet. */ /* */ /* You may freely copy and modify this script to suite your own */ /* requirements. */ /* */ /* ---------------------------------------------------------------- */ \n"; $data_num = 1; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach ($line as $col_value) { print "data".$data_num."series1: ".$col_value."\n"; } $data_num = $data_num +1; } /* Performing SQL query for Product Y*/ $query = "Select Value from SalesBar where Year=2004 and Product='Y' ORDER BY Month"; $result = mysql_query($query) or die("Query failed : " . mysql_error()); /* Construct the return data for Product Y */ print "\n"; $data_num = 1; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach ($line as $col_value) { print "data".$data_num."series2: ".$col_value."\n"; } $data_num = $data_num +1; } /* Free resultset */ mysql_free_result($result); /* Closing connection */ mysql_close($link); ?>