Click here to Skip to main content
15,607,634 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to draw a graph from the values i have in my table in database..
E.g, i have a table age in my database.. I have a form in html where i will display the graph.. I want to get a graph displaying the different age i have in my table..
Can you help me..
thank uu..

1 solution

There could be many different ways. Basically, you can generate any graphics out of your data on the server side, save it in a temporary file, or provide graphics content on the fly prescribing proper media type in your HTTP response. With PHP, it can be anything. It could be something like "image/png", "image/jpeg", etc. Please see:[^],[^],
the ultimate document on available MIME types is this one (for images):[^].

So, in your PHP script, it could be something like
header('Content-type: image/png');
/* or */
header('Content-type: image/jpeg');

For generation of general graphics, there are many libraries (like ImageMagick,[^]).

This is how it works. In practice, you can find some read-to-use open-source charting library:[^].

There is a very attractive alternative approach: using HTML5 Canvas feature:[^].

For example, this product:[^].

You can find more:[^].

If you use this approach, your PHP code should be used to generate data and Javascript needed to present graphics. The attractiveness of this approach is that you can make graphics (especially changing view options, limits, etc.) on the fly with great performance, because all such processing can be done purely on client side.

Share this answer
Maciej Los 19-Mar-14 17:18pm    
Sergey Alexandrovich Kryukov 19-Mar-14 17:34pm    
Thank you, Maciej.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900