Pages

Displaying MySql data in drop down box - PHP

The following PHP code will display the names from the table "results" in a drop down box.

Table is:
id name Maths English Science
1 AAA 87 65 98
2 BBB 65 76 45
3 CCC 98 80 99
4 DDD 65 45 47
5 EEE 34 54 43
6 FFF 32 76 65
7 GGG 54 65 76
The Code is:

 The Output is:

RGraph - Creating a bar chart using PHP

Here we go, Creating charts using data from MySql using PHP. The charting plugin we going to use rgraph which is an open source and you can download it from here. The rgraph libraries are written wih javascrit and it has made it easy like we just need to populate the values and we get the graph for the data.

Creating a bar graph:
Before we draw the graph we need to create a database and a table in MySQL. You can follow the steps hereLets get into the important stuff now,

  • After creating the table, create a new folder in htdocs folder give any name without space. 
  • Move the libraries folder from the rgraph zip file which you have downloaded from the above link.
  • Create a PHP file in the same folder and copy paste the below code.

below is the PHP code for the Bar Chart.


Similarly we can create different charts like line, pie, horizontal, etc. These charts proerties can be changed and we can make it even more better. It will appear in default variant if properties not changed.

Different Rgraphs available are,
  • Bar charts
  • Bi-polar charts
  • CornerGauge charts
  • Donut charts
  • Fuel charts
  • Funnel charts
  • Gauge charts
  • Gantt charts
  • Horizontal bar charts
  • Horizontal progress bar
  • LED Grid
  • Line charts
  • Meter charts
  • Odometer charts
  • Pie charts
  • Radar charts
  • Rose charts
  • Radial scatter charts
  • Scatter charts
  • Thermometer charts
  • Vertical progress bar
  • Waterfall charts