title: how to get specific data from two tables?
body: <p>i have following tables<br>
  comments table:<br></p>
  
  <pre><code>id  user_id question_id comment 
  1     2        3          hii   
  </code></pre>
  
  <p>users table:<br></p>
  
  <pre><code>id    u_name   user_image 
  2     naveen     a.jpg 
  </code></pre>
  
  <p>when question_id=3 is selected how to print values like this:<br></p>
  
  <pre><code>user_image     u_name    comment
  a.jpg          naveen      hii &lt;br&gt;
  </code></pre>
  
  <p>sql query:<br></p>
  
  <pre><code>$sql = "SELECT u.user_image, u.name, c.comment
  FROM users u INNER JOIN comment c
      ON u.id = c.user_id
  WHERE c.question_id = 2"; 
  
  $result = mysqli_query($conn, $sql);
  if (mysqli_num_rows($result) &gt; 0) {
      // output data of each row
  while($rows = mysqli_fetch_assoc($result)) {
  echo '&lt;td class="small"&gt;'.$rows['name'].'&lt;/td&gt;';
  echo '&lt;td class="small"&gt;'.$rows['user_image'].'&lt;/td&gt;';
  echo '&lt;td class="small"&gt;'.$rows['comment'].'&lt;/td&gt;';
  
  }
  } 
  else {
      echo "0 results";
  }
  </code></pre>