title: retrieve data from two tables of a database and show it using php
body: <p>I have created a database named (insert) having two tables table1 and table 2.</p>
  
  <p><code>table1</code> have 3 columns <code>user, id, roll</code>.</p>
  
  <p><code>table2</code> have 2 columns <code>id, menu</code>. </p>
  
  <p>I have inserted values in two  tables.  I want to retrieve all values from two tables and show them in another php file, but my query is not working.  It's showing error.  What should I do?  here is my code </p>
  
  <pre><code>&lt;?php
  
  include 'insertjoincon.php';
  $sql = "SELECT table1.user, id FROM table1, table2 WHERE    table1.id=table2.id";
  
  echo "&lt;table border=1&gt;\n&lt;tr&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;ID&lt;/th&gt;&lt;/tr&gt;\n";
  
  while ($line = mysql_fetch_array($sql)) {
      $name = $line["user"];
      $id = $line["id"];
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;" . $name . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $id . "&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  
      echo "&lt;/table&gt;";
  }
  
  $conn-&gt;close();
  ?&gt;
  </code></pre>