0
私は以下のGoogle Charts
コードを持っています。私はMySQL
と接続しようとしていますが、インターネット上で利用できるものはすべて試しましたが、まだ10個のエントリがありますが、 。インターネット上で私は$row_num
のものを見つけ、それを私のコードに含めて以来、私は1つのエントリを照会することができましたが、それを使ってすべてのエントリを照会したいのです。私のPHPコードされた後、これで私を助けて、私は、私が作っているものを間違い(もしあれば)教えてください:Google Chartsに接続したときにMySQLのエントリが1つだけ表示されますか?
[<?php
``$dbhandle= new mysqli('localhost','root','8317','record');
//echo $dbhandle->connect_error();
$query= "SELECT * from download_manager";
$res= $dbhandle->query($query);
?>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':\['bar'\]});
google.charts.setOnLoadCallback(drawStuff);
function drawStuff() {
var data = new google.visualization.arrayToDataTable(\[
\['Title', 'No. of Downloads'\],
<?php
$total_rows = mysqli_num_rows($res);
$row_num = 0;
if (mysqli_num_rows($res) > 0) {
while($row=$res->fetch_assoc())
{
$row_num++;
if ($row_num == $total_rows){
echo "\['".$row\['filename'\]."',".$row\['downloads'\]."\]";
}
}
}
else
{
echo "0 results";
}
?>
\]);
var options = {
width: 800,
chart: {
'title': 'Top 10 Downloads',
subtitle: 'for the last month'
},
bars: 'horizontal', // Required for Material Bar Charts.
axes: {
}
};
var chart = new google.charts.Bar(document.getElementById('dual_x_div'));
chart.draw(data, options);
};
</script>
</head>
<body>
See Also : <a href="barchart1.html"> Downloads in the Last 7 Years </a> <br> <br>
<div id="dual_x_div" style="width: 900px; height: 500px;"></div>
</body>
</html>][1]
トリックは本当にありがとうでしたか? –