Get total views per day including leaving “0 views” for a day that has no record

前端 未结 2 1120
轻奢々
轻奢々 2021-01-22 07:01

I am creating a graph where I can get the total views everyday for a certain range, or as long it goes back.

The problem I am having is to fill a default number of

2条回答
  •  渐次进展
    2021-01-22 07:06

    When I did this a couple of years ago I created an empty array with the date as key and the default value 0. Then I simply looped through the result att changed the value for those dates I had.

    for each($result as $row){
       $date_stats_array[$row['date']] = $row['value'];
    }
    

提交回复
热议问题