PHPBuilder - Dynamic Graphs with PHP, MySQL and GD



RSS Twitter
Articles Php Functions

Dynamic Graphs with PHP, MySQL and GD

by: Ramsey Nasser
|
February 19, 2003

Ok. Your site has recorded the data you want, now you want to display it in an easy to read format. The first method that comes to mind is simply to put the data in an HTML table. Although this is probably the easiest way out, there is a much better way of displaying your information: a graph. This was originally only possible by using sneaky tables with <tr>'s of different lengths. But now, thanks to the GD library and PHP, you can actually have a PNG or JPG image generated dynamically from data in a MySQL database. This article will help you start out in dynamic image generation.
Requirements
The technical requirements for this article are listed below:
  • PHP Scripting language (obviously): Without this language, this article is absolutely useless. If you don't have it, stop reading and get it now!
  • MySQL Server: For data storage. Any other SQL (Oracle, MSQL, etc.) would be fine, this is just my personal preference. The queries in this article were written for MySQL, however, and to use another SQL would mean you would have to translate them.
  • GDLib: An extension to PHP that offers image manipulation capabilities. It can be found at http://www.boutel.com/gd. Installation of this extension is unique to each environment that it is being set up in, and will not be covered.
  • Any paint program: To draw the base image for the graph (there is not artistic talent required, don't worry).
Once you have all of these set up and running, you are ready to start coding.

1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Ramsey Nasser

Comment:



Comment:

(Maximum characters: 1200). You have characters left.