php-如何使用php数组在图表js中显示数据

时间:2019-09-26 15:20:07

标签: javascript php mysql charts

我会保持简单,我是php的新手,而现在我已经开始使用chart js。所以我的应用程序是一个点击计数器,它从数据库中获取点击并将其显示给用户仪表板。但是问题是,我已经知道如何将数据显示为图表js,但如何将数据库中的数据转换并存储在php数组中,然后可以在图表js中显示它。

这是我的php代码

 $previous_date = (new DateTime())->modify('-15 day')->format('Y-m-d');
        if($result = $dbqueries->Query("SELECT COUNT(`id`) AS `total`, DATE(`date`) AS `date` FROM `hits` WHERE `userId` = ? AND `date` > ? GROUP BY DATE(`date`) ORDER BY `date` DESC", [$userId, $previous_date])){
//Also the $userId is the session of the user through which I can get the particular user
            $row = $dbqueries->fetch();
            $date = $row->date; //getting date of the hit
            $total = $row->total; //getting the total number of hits from a particular user Id

        }

现在,在此之后,我没有得到如何将数据存储在数组中并在图表js中显示它的信息,我也尝试了几行代码,但这是错误的,它显示“执行时间超出了”。

我们将不胜感激

0 个答案:

没有答案