hi guys l wanted to know that it is it possible generated diagrams in php....what l mean is that l am doing an online exam project and some of the exam questions must have graphs or diagrams on them so how can this be done to output these diagrams.......

the project is in php with mysql db......

Yes it's possible. Although it may take some time to code (and render) each graph.
I'd look at fusioncharts. They provide a free trial which have the best PHP-driven charts.
Alternatively, if you can generate images of these graphs (or if they don't need to be dynamic) then simply display the image. This would save you a lot of time.

Member Avatar


If you're using static pictures or graphs, you could upload the graphic and store the filepath to a DB along with the rest of the question. You could also store the actual file itself in a BLOB field if you so wanted.

A typical MySQL table could be:

exam_question_id (PK)
exam_id (FK)
question_no (usually numerical - purely for grouping questions and adding max_marks)
question_label (e.g. '2.' or '(a)' or '(i)' or I - purely for display)
ranked_order (question order for the specific exam, so that the questions appear in the correct order)
max_marks (maximum number of marks awarded for a question)
pre_graphic_question_text (the usual question, regardless if there is a graphic)
graphic (filepath or BLOB)
post_graphic_question_text (second part of the question to appear after the graphic if there is one)

The above is very simplified, but you get the idea. You could have additional fields for answer types, like tickbox, extended prose, select from list, fill in the blanks etc.

The greater the number of options, the more complex the table(s).

You could even have assessment fields for automated marking or an individual marking scheme for questions so that users could check their answers.

Alternatively, you could place a question in one field as html. Just upload all graphics to a common folder and reference your IMG tags appropriately - that should be easier.

hey, probably not the best thing to do, but in 2009 i needed to display figures of what people have achieved in my business, i had a mySQL DB that had all their figures in, i did a quick php call to retrieve the figures, then set my img tag to:


<img src="images/blue.gif" width="20px" height="<?=$php_figures;?>" alt="figures" />

it worked for a small internal project so i was happy, but i dont recommend this way :)

or if i wanted it :


<img src="images/blue.gif" width="<?=$php_figures;?>" height="20px" alt="figures" />

thank u guys for all the great ideas they are quite helpful