title: for loop display undesired result php
body: <p>The output of the result for the php i created is like this :</p>
  
  <blockquote>
    <p>{"result":[{"day":"1","count":"0"}]}{"result":[{"day":"2","count":"0"}]}....</p>
  </blockquote>
  
  <p>but i want the output of the result :</p>
  
  <blockquote>
    <p>{"result":[{"day":"1","count":"0"},{"day":"2","count":"0"}...]</p>
  </blockquote>
  
  <p>The following is my php code:</p>
  
  <pre><code>&lt;?php
  
   define('HOST','xx');
   define('USER','xx');
   define('PASS','xx');
   define('DB','xx');
  
  
   //$month = $_POST['month'];
   //$year = $_POST['year'];
  
   $month = 10;
   $year=2016;
  
  
   $con = mysqli_connect(HOST,USER,PASS,DB);
  
   $sql = "select count(entryID) from Entry where
        EXTRACT(DAY FROM(entryTime)) = '$day'  AND
        EXTRACT(MONTH FROM(entryTime)) = '$month' AND 
        EXTRACT(YEAR FROM(entryTime))= '$year'";
  
   for($day =1 ; $day&lt;31 ; $day++)
   {
   $day2 = (string)$day;
   $res = mysqli_query($con,$sql);
  
   $result = array();
   while($row = mysqli_fetch_array($res)){
   array_push($result,
   array('day' =&gt;$day2,
      'count' =&gt; $row[0]
   ));
  
   }
  
   }
   echo json_encode(array("result"=&gt;$result));
  
  
   mysqli_close($con);
  
   ?&gt;
  </code></pre>
  
  <p>Asking for help..</p>