
In this example, we will introduce a technique where the database query is performed in the containing HTML page, and the data is passed to the ChartDirector script as HTTP GET query parameters. Using this method, it is possible to perform one database query and feed the data to multiple charts.
The user will select a year from a HTML form and press OK. The web server will query a database to obtain the necessary data, and return a web page containing the bar chart and the line chart for the selected year.
The code for producing the HTML form is listed below.
The code outputs a drop down select list to allow the user to selecte a year. Based on the selected year, it queries the database and read the data into arrays. The data are then serialized into comma delimited strings using the "join" function. Two <IMG> tags are used to invoke two scripts for charts generation, where the data are passed in as HTTP GET query parameters using the comma delimited strings.
[The following is available as "perldemo_cgi/dbdemo2_main.pl".]
Database Integration Demo (2)This example demonstrates creating a chart using data from a database. The database query is performed in the containing HTML page. The data are then passed to the chart generation pages as HTTP GET parameters.
|