title: Looping through ..array push in php
body: <pre><code>$query = "SELECT * from tblTwigUsers;";
      $result = mysqli_query ($con,$query);
  
  if (mysqli_num_rows($result)&gt;0)
      {
          $response = array();
          $code = "profile_true";
          while($row = mysqli_fetch_array($result))
          {
              array_push    ($response,array("code"=&gt;$code,"fldUser_Id"=&gt;$row[0],"fldUser_UserName"=&gt;$row[2]));   
              echo json_encode(array("server_resposnse"=&gt;$response));
          }
      }
  else
      {   
          $response = array();
          $code = "profile_false";
          $message = "failed to get user profile info...";
          array_push ($response,array("code"=&gt;$code,"message"=&gt;$message));
          echo json_encode(array("server_resposnse"=&gt;$response));  
      }
  </code></pre>
  
  <p>Result</p>
  
  <pre><code>    {
      "server_resposnse": [{
          "code": "profile_true",
          "fldUser_Id": "1",
          "fldUser_UserName": "sohan"
      }]
  } {
      "server_resposnse": [{
          "code": "profile_true",
          "fldUser_Id": "1",
          "fldUser_UserName": "sohan"
      }, {
          "code": "profile_true",
          "fldUser_Id": "2",
          "fldUser_UserName": "sonal"
      }]
  } {
      "server_resposnse": [{
          "code": "profile_true",
          "fldUser_Id": "1",
          "fldUser_UserName": "sohan"
      }, {
          "code": "profile_true",
          "fldUser_Id": "2",
          "fldUser_UserName": "sonal"
      }, {
          "code": "profile_true",
          "fldUser_Id": "3",
          "fldUser_UserName": "amit"
      }]
  } {
      "server_resposnse": [{
          "code": "profile_true",
          "fldUser_Id": "1",
          "fldUser_UserName": "sohan"
      }, {
          "code": "profile_true",
          "fldUser_Id": "2",
          "fldUser_UserName": "sonal"
      }, {
          "code": "profile_true",
          "fldUser_Id": "3",
          "fldUser_UserName": "amit"
      }, {
          "code": "profile_true",
          "fldUser_Id": "4",
          "fldUser_UserName": "rajiv"
      }]
  }
  </code></pre>
  
  <p>Why is the data repeating ? 
  The 4th result is the correct one , I need that ? How to get it?
  Help appreciated,</p>
  
  <p>Thx,
  Sohan</p>