Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php highcharts-在mysql查询中没有任何要渲染的情况下显示无数据图片_Php_Mysql_Highcharts - Fatal编程技术网

Php highcharts-在mysql查询中没有任何要渲染的情况下显示无数据图片

Php highcharts-在mysql查询中没有任何要渲染的情况下显示无数据图片,php,mysql,highcharts,Php,Mysql,Highcharts,我一直在这里和互联网上寻找一个解决方案,当查询没有从数据库返回任何东西时,在highcharts的DIV上显示一个无数据图片 mysql查询 $GetData= "SELECT COUNT( * ) AS `items count` , `items` FROM `items` where repdate = curdate() GROUP BY `items` ORDER BY `items count` DESC "; 我的表格代码 <table width="31

我一直在这里和互联网上寻找一个解决方案,当查询没有从数据库返回任何东西时,在highcharts的DIV上显示一个无数据图片

mysql查询

$GetData= "SELECT COUNT( * ) AS  `items count` ,  `items` 
FROM  `items` 
where repdate = curdate()
GROUP BY  `items` 
ORDER BY  `items count` DESC  ";
我的表格代码

<table width="313" id="datatable" style="display:none;">
 <thead>
 <tr>
            <th>column 1</th>
            <th>column 2</th>
        </tr>
        </thead>
        <tbody>
    <?php

    while ($row = mysql_fetch_array($GetData)) {
        echo "<tr>";
        echo "<th>" . $row['items'] . "</th>";
        echo "<td>" . $row['items count'] . "</td>";
        echo "</tr>";
    }
  ?>
</tbody>
</table>

第1栏
第2栏
例如:

在mysql查询不返回任何数据的情况下,我得到以下结果

如果没有返回数据,如何停止highcharts渲染?并用图片替换它


类似示例

您可以检查选项变量以查看是否有任何数据,并仅在数据存在时呈现图表

if (options.series.length > 0) {
  var chart = new Highcharts.Chart(options);
}

在没有数据的情况下,我的查询像“items count”一样返回,这与上述内容不符,因为序列计数从第一行开始,而我不能在返回时循环表头。。任何其他解决方案然后为实际数据添加一个计数器,并在渲染图形之前进行检查:)