title: How to fetch specific column data from the different tables in php/mysql
body: <p>I'm creating  a website on teacher and student database in php, i have done almost all things in mysql database but i want to fetch specific data from the table, like i want to choose "prof. vaidya sir" from column "name" and display professor related all data.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;?php   
  include 'dbh.php';
  $name = "Prof. Vaidya Sir";
  $class ="BE";
  $sqll = "SELECT feedback1.erp,feedback1.class,feedback2.name,feedback2.ability,feedback2.knowledge,feedback2.accessbility,feedback2.attitude FROM feedback1, feedback2 WHERE feedback1.erp=feedback2.erp";
  $result = $conn-&gt;query($sqll);
  ?&gt;
  &lt;table border="2"&gt;
    &lt;thead&gt;
      &lt;tr&gt;&lt;th&gt;erp&lt;/th&gt;&lt;th&gt;class&lt;/th&gt;&lt;th&gt;name&lt;/th&gt;&lt;th&gt;ability&lt;/th&gt;&lt;th&gt;knowledge&lt;/th&gt;&lt;th&gt;accessbility&lt;/th&gt;&lt;th&gt;attitude&lt;/th&gt;&lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;?php
        if($result-&gt;num_rows &gt; 0)
           {
              while ($row = $result-&gt;fetch_assoc()){
  
               echo "&lt;tr&gt;&lt;td&gt;{$row["erp"]}&lt;/td&gt;&lt;td&gt;{$row["class"]}&lt;/td&gt;&lt;td&gt;{$row["name"]}&lt;/td&gt;&lt;td&gt;{$row["ability"]}&lt;/td&gt;&lt;td&gt;{$row["knowledge"]}&lt;/td&gt;&lt;td&gt;{$row["accessbility"]}&lt;/td&gt;&lt;td&gt;{$row["attitude"]}&lt;/td&gt;&lt;/tr&gt;\n";
  
          }   
          else{echo "0 results";
          }
  ?&gt;
   &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>This is output of above code</strong></p>
  
  <p><img src="https://i.stack.imgur.com/Cits4.png" alt="This is output of above code"></p>