Area Chart using Google Charts API in PHP MySQLi

Area Chart using Google Charts API in PHP MySQLi

In this Post We Will Explain About is Area Chart using Google Charts API in PHP MySQLi With Example and Demo.Welcome on Live24u.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to Create a Simple Area Chart using Google Charts API Example

In this post we will show you Best way to implement Google Charts or graph with PHP, Mysqli and AJAX, hear for Data Visualisation with the Google Chart, PHP and MySQLi with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :   Creating Dynamic Email Template in PHP




here simple, we make the main root page where we simple present the Google chartData using PHP area chart. MAke a new file Like as, name it as Create Google Charts or graph with PHP, Mysqli and AJAX index.php as well as all the source copy paste the script below.

<?php
	//Google Charts or graph with PHP, Mysqli and AJAX
	//connection
	$db_con = new mysqli('localhost', 'user_name', 'YOUR_PASSWORD', 'live24u');
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Google Charts or graph with PHP, Mysqli and AJAX</title>
</head>
<body>
<div id="live_my_araea_graph" style="width: 1000px; height: 700px;"></div>
 
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script" rel="nofollow">https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
//Data Visualisation with the Google Chart, PHP and MySQL

  	google.charts.load('current', {'packages':['corechart']});
  	google.charts.setOnLoadCallback(makeGraph);
 
  	function makeGraph() {
    	var chartData = google.visualization.arrayToDataTable([
    		['Year', 'Students', 'Fees'],
    		<?php
	      		for($i = 2018; $i <= 2022; $i++){
	      			//students
	      			$live_sql = "SELECT sum(students) AS total_students FROM students WHERE year(date) = '$i'";
	      			$stud_query = $db_con->query($live_sql);
	      			$stud_rows = $stud_query->fetch_assoc();
	      			//Students Fees
	      			$live_sql = "SELECT sum(fees) AS total_fees FROM fees WHERE year(date) = '$i'";
	      			$fees_query = $db_con->query($live_sql);
	      			$fees_row = $fees_query->fetch_assoc();
	      			//displaying the student needed chartData
	      			echo '["'.$i.'", '.$stud_rows['total_students'].', '.$fees_row['total_fees'].'],';
	      		}
	      	?>
      		// 
      		// ['2018',  1000,400],
      		// ['2019',  2570,460],
      		// ['2020',  660,2420],
      		// ['2021',  1030,1540]
    ]);
 
    var live_g_setting = {
      	title: 'Atmiya Collage',
      	hAxis: {title: 'Year',  titleTextStyle: {color: '#c60000'}},
      	vAxis: {minValue: 0}
    };
 
    var livechrt = new google.visualization.AreaChart(document.getElementById('live_my_araea_graph'));
    livechrt.draw(chartData, live_g_setting);
 
  	}
</script>
</body>
</html>

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Also Read :   Pagination with jQuery Ajax PHP and MySQL





Example

I hope you have Got What is PHP MySQLi Google Chart JSON And how it works.I would Like to have FeedBack From My Blog(live24u.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(live24u.com) Are Most Always Welcome.