<?php
$pas='sf0.&hx$S}si';
$conn = new PDO("mysql:host=localhost;dbname=ipqjsilq_sch","ipqjsilq_school",$pas);
if(isset($_POST["action"]))
{
      $query="SELECT pupils.Claz as claz, count(pupils.count) AS Total  FROM pupils where pupils.Status='Active' GROUP BY claz";  
	  $result = $conn->query($query);
	  $data = array();

		foreach($result as $row)
		{
			$data[] = array(
				'claz'		=>	$row["claz"],
				'total'			=>	$row["Total"],
				'color'			=>	'#' . rand(100000, 999999) . ''
			);
		}
		echo json_encode($data);
}
?>