title: How to convert mysqli_fetch_assoc results into json format?
body: <p>i am trying to convert the result of my query into a json format so i can grap it with jquery in another file. I dont get any errors but its not recognised as json.</p>
  
  <pre><code>    $patientquery = mysqli_query($connect, "SELECT * FROM login WHERE assignedTo='$logID'");
  
      $numrows = mysqli_num_rows($patientquery);
  
      if($numrows &gt; 0)
      {
          while($rows = mysqli_fetch_assoc($patientquery))
          {
              $dbloginID = $rows['loginID'];
              $dbname = $rows['name'];
  
  
              $result[] = array('patient'=&gt;array('id' =&gt; $dbloginID, 'name' =&gt; $dbname));
  
  
          }
      }
      else
      {
          $result[] = 'No Patients yet';
      }
  
  echo json_encode($result);
  </code></pre>