I've made a little modification, so then now i see the chart but something 
wrong, all value in same column. Picture attached. Thank's the help.


[image: chart.jpg]


data.addRows([
        <?php
if(mysqli_num_rows($result) > 0) {

while($row = mysqli_fetch_array($result)) {

$datum = $row['datum'];
$datum_formated = date_format($datum, "Y, m, d");
$ertek = $row['ertek'];

?> [new Date(<?php echo $datum_formated; ?>), <?php echo $ertek; ?> ], <?php

}

}
?>
    ]);
László Horváth a következőt írta (2024. január 23., kedd, 15:37:35 UTC+1):

> Dear Group!
>
> I have a php code with a google chart. I've try everything but it doesn't 
> work for me.
> I have two variable: 
> Date: format like: '2024-01-23 14:36:43'
> Value: format like: '234'. 
> This values come from mysql.
>
> The error code is: Uncaught SyntaxError: missing ) after argument list (at 
> index.php:17:33)
>
> Thanks for your help and advice!
>
> H.Laszlo
>
> https://developers.google.com/chart/interactive/docs/datesandtimes
>
> <?php
>     $connection = mysqli_connect('localhost', 'xxxx', 'xxxx', 'database');
>     $result = mysqli_query($connection, "SELECT id, date, value FROM 
> table");
>
> ?> 
> <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 = new google.visualization.DataTable();
>         data.addColumn('date', 'Time of Day');
>         data.addColumn('number', 'Rating');
>
>     data.addRows([
>         <?php
>         if(mysqli_num_rows($result) > 0) {
>
>             while($row = mysqli_fetch_array($result)) {
>
>                 $datum = $row['date'];
>                 $ertek = $row['value'];
>
>                 ?> [new Date( <?php echo $row['date']; ?> ), <?php echo 
> $row['value']; ?> ], <?php
>             }
>
>         }
>         ?>
>     ]);
>     
>     
>     var options = {
>           title: 'Rate the Day on a Scale of 1 to 10',
>           width: 900,
>           height: 500,
>           hAxis: {
>             format: 'Y/m/d h:m:s',
>             gridlines: {count: 15}
>           },
>           vAxis: {
>             gridlines: {color: 'none'},
>             minValue: 0
>           }
>         };
>
>         var chart = new 
> google.visualization.LineChart(document.getElementById('chart_div'));
>
>         chart.draw(data, options);
>
>         var button = document.getElementById('change');
>
>         button.onclick = function () {
>
>           // If the format option matches, change it to the new option,
>           // if not, reset it to the original format.
>           options.hAxis.format === 'M/d/yy' ?
>           options.hAxis.format = 'MMM dd, yyyy' :
>           options.hAxis.format = 'M/d/yy';
>
>           chart.draw(data, options);
>         };
> }
>
>     </script>
>   </head>
>   <body>
>     <div id="chart_div"></div>
>   </body>
> </html>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Chart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-chart-api/c368af2a-3967-4e64-87cb-724cad3fbfb2n%40googlegroups.com.

Reply via email to