<html>
    <head><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400"> 
<style>
  
  body {
    font-family: 'Open Sans';font-size: 22px;
    } 
select
{
    width:300px;
}
</style></head><body>
<?php
function select_pacients_by_location($lok)
{
     $conn = mysqli_connect("localhost","tagstudi_aldina","aldina1234567","tagstudi_ehealth");
   if (!mysqli_connect_errno())
   {
       
  $sql = "SELECT count(*) as broj FROM `morbili_new2` where `lokacija_pruzanja_usluga` like '".$lok."%' and  `datum_pruzene_usluga` like '2018%'";
  $result= $conn->query($sql);  
  if ($result->num_rows > 0) {
   
    while($row = $result->fetch_assoc()) {
      $rezultat=$row["broj"];
     
    }
    return $rezultat;
  }
   else
      {
          echo "Zero rows!";
      }}
  else
  {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      
  }
   
}
?>
                                 <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([
          ['Task', 'Pregled broja pacijenata obolelih od morbila po zdravstvenim stanicama'],
          ['Centralna zgrada',     <?php echo select_pacients_by_location('Centralna zgrada');?>],
          ['Ledena Stena',      <?php echo select_pacients_by_location('Ledena stena');?>],
          ['Delijski vis',      <?php echo select_pacients_by_location('Delijski vis');?>],
          ['Duvanište',      <?php echo select_pacients_by_location('Duvanisxte');?>],
          ['Ratko Pavlović',     <?php echo select_pacients_by_location('Ratko Pavlovicy');?>],
          ['Branko Bjegović',      <?php echo select_pacients_by_location('Branko Bjegovicy');?>],
          ['Donja Vrežina',      <?php echo select_pacients_by_location('Donja Vrezxina');?>],
          ['Lira',      <?php echo select_pacients_by_location('Lira');?>],
          ['Novo selo',     <?php echo select_pacients_by_location('Novo selo');?>],
          ['Nikola Tesla',      <?php echo select_pacients_by_location('Nikola Tesla');?>],
          ['Niška Banja',      <?php echo select_pacients_by_location('Nisxka Banja');?>],
          ['12. februar',      <?php echo select_pacients_by_location('12. februar');?>]
          
        ]);

        var options = {
          title: 'Pregled broja pacijenata obolelih od morbila po zdravstvenim ustanovama',
          pieHole: 0.1,
        };

        var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
        chart.draw(data, options);
      }
    </script>
    <div id="donutchart" style="width: 100%; height: 600px;"></div>
       </body></html>