Google Charts or graph using Google Chart API with PHP MySQLi

Google Charts or graph using Google Chart API with PHP MySQLi

In this Post We Will Explain About is Google Charts or graph using Google Chart API with 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 Create Dynamic Pie Chart using Google Chart API with PHP MySQLi Example

In this post we will show you Best way to implement Create Dynamic Pie Chart in PHP with Google Charts, hear for How to Create a Simple Pie Chart using Google Chart API with PHP/MySQLi with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :   PHP Print Pyramid of Stars Pattern Triangle Program




Simple, I make the HTML page where I display the custom data using pie chart. Make a new create file, Like name as index.php and simple copy and paste the source codes below.

<?php
//Create Dynamic Pie Chart using Google Chart API with PHP MySQLi
	//Database connection
	$db_conn = new mysqli('localhost', 'root', 'YOUR_PASSWORD', 'live24u');
 
	$lstsql = "SELECT gread, count(*) as number FROM students GROUP BY gread";
	$query = $db_conn->query($lstsql);
 
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>How to Create a Simple Pie Chart using Google Chart API using PHP/MySQLi</title>
	<link rel="stylesheet" type="text/css" href="Live24u/bootstrap/css/bootstrap.min.css">
</head>
<body>
<!--Live24u.com this is where we show simple chart -->
<div id="piechart" style="width: 900px; height: 600px;"></div>
 
<!--Live24u.com Load simple Scripts -->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">  
	google.charts.load('current', {'packages':['corechart']});  
	google.charts.setOnLoadCallback(drawChart);  
	function drawChart(){  
    var data = google.visualization.arrayToDataTable([  
              	['Gread', 'Number'],  
              	<?php  
	              	while($liveRow = $query->fetch_assoc()){  
	               		echo "['".$liveRow["gread"]."', ".$liveRow["number"]."],";  
	              	}  
              	?>  
         	]);  
    var dbdataoptions = {  
          		title: 'Percentage of User Pass and Fail Students',  
          		//live24u.com is3D:true,  
          		pieHole: 0.4  
         	};  
    var chart = new google.visualization.PieChart(document.getElementById('piechart'));  
    chart.draw(data, dbdataoptions);  
}  
//how to create dynamic pie chart in php or javascript with mysql
</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 :   Angularjs Datatables Server Side Processing in PHP and MySQLi





Example

I hope you have Got What is How to Create a Simple Pie Chart using Google Chart API with PHP/MySQLi 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.