Home » Php » how to display empty date range in php mysql

how to display empty date range in php mysql

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am trying to display a chart of orders placed within the last 30 days but where there are zero orders, the script simply omits that date. What is the best way I can run the script so that it passes those dates with zero orders into the JS chart script?

For example, the below will show 1 order each for the 16th, 15th and the 13th. but how can I also add to the loop 0 orders for the 14th?

id - name - datetime
1  - name1 - 2020-02-16
2  - name2 - 2020-02-15
3  - name3 - 2020-02-13

I understand there are ways of doing it by creating another table but how can I do it in PHP? Or, is doing it in MySQl better?

How to&Answers: