Anyone let me know how do i create a line chart using PHP and JS with the my code mentioned below? (fix the errors) [closed]

Here’s My DB connection
connection is stable and working

<?php
$servername= "localhost";
$username="root";
$password="";
$dbname="linechart";
$conn=new mysqli($servername, $username, $password, $dbname);
if ($conn){
}
else{
    echo "Connection Failed";
}

Here I mentioned the code that need to be fixed
whenever i tried to get the run the code; i met with the blank screen having no output…

<?php include "db.php";?>
<html>
  <head>
    <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([
          ['dates', 'sources', 'magnitude'],
          <?php
              $query="select * from linechart";
              $res=mysqli_query($conn, $query);
              while ($data=mysqli_fetch_array($res)){
                $dates=$data['dates'];
                $sources=$data['sources'];
                $magnitude=$data['magnitude'];
          ?>
          ['<?php echo $dates;?>',<?php echo $sources;?>,<?php echo $magnitude;?>]
          <?php
              };
          ?>
        ]);
        var options = {
          title: 'SUMMARY',
          curveType: 'function',
          legend: { position: 'bottom' }
        };

        var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="curve_chart" style="width: 900px; height: 500px"></div>
  </body>
</html>

Thanks in advance …