title: Creating a PHP API (Convert data from mySQL to JSON);
body: <p>So my 1st target is to convert expecting data from mySQL as JSON before use XML.
  Things i trying to solve- Connect two tables from database for specific user and display it on screen.</p>
  
  <p>Everything is in one PHP file:</p>
  
  <pre><code>&lt;?php
  include 'db.php';
   session_start();
    ob_start();
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  $sql = "SELECT * FROM users 
  INNER JOIN user_quiz ON users.user_uid = user_quiz.user_uid
  WHERE users.user_uid = '".$_SESSION['u_uid'] ."'";
  $result = $conn-&gt;query($sql);
  if ($result-&gt;num_rows &gt; 0) {
      // output data of each row
      while($row = $result-&gt;fetch_assoc()) {
          $outp = array();
          $outp = $result-&gt;fetch_all(MYSQLI_ASSOC);
  // for check if record exist
            echo "&lt;br&gt; id: ". $row["id"]. " - Name: ". $row["user_first"]. " " . $row["user_last"] . " id:" . $row["user_uid"] . " Selected qustion " . $row["q_topic"] . " ". $row["q_id"] .  "&lt;br&gt;";
  
      }
  } else {
      echo "0 results";
  }
  
  
  $myJSON = json_encode($outp);
  
  echo $myJSON;
  ?&gt;
  </code></pre>
  
  <p>So now where is a issue.. When i do SQL like that:
   SQL:</p>
  
  <pre><code>$sql = "SELECT * FROM users";  
  </code></pre>
  
  <p>PHP is convert data as JSON data... but when i trying to do that for specific user i have empty []... That's why i use echo to see if i have output or i have error but... i have displays value...  Had no idea what's going on... need advice.</p>