SQL query for calculate cont of orders for each day : <p>Have a table:</p>

<pre><code>order_id | time_order
1 | 2018-10-10 12:22:05
2 | 2018-10-11 05:22:05
4 | 2018-10-12 07:22:05
5 | 2018-10-12 15:25:05
...
</code></pre>

<p>I need to calculate orders count for each day in time interval and make a string like $str = '1, 1, 2, 0...'. If no orders some of days - 0.</p>

<p>Trying query like this:</p>

<pre><code>    $query = $mysqli-&gt;query("SELECT COUNT(*) FROM orders WHERE DATE(time_order) &gt;= DATE(NOW()) - INTERVAL 7 DAY GROUP BY time_order");
    while( $row = mysqli_fetch_row($query) )
{
    $str .= ','.json_encode($row,true);
}
</code></pre>

<p>But result is 1,1,1,1,1,1,1,1,1,1,1,1,1,1...</p>

<p>Please, advise how to make right query?</p>

<p>Thanx!</p>
