title: Join two tables in Php
body: <p>I have two tables</p>
  
  <p>Table 1 category</p>
  
  <pre><code>Id    name      img   
  1   appliances   
  2   books
  </code></pre>
  
  <p>Table 2 products</p>
  
  <pre><code>ID  name des  price  cataegory sub  img
  1  TV    lcd  125     1        tv
  </code></pre>
  
  <p>I am trying to join the two tables that in category in table 2 till get the name from table 1</p>
  
  <p>This is my code</p>
  
  <pre><code>    $sql = "SELECT p.id, 
                     p.name,
                     p.description, 
                     p.price,
                     c.name,
                     p.sub
              FROM products p
              JOIN category c on products p = c.id
              ORDER by p.id
              ";
  
      if($query =  mysql_query($sql) or die())
      {
          while($result = mysql_fetch_assoc($query))
          {   echo "&lt;tr id='id'&gt;";
              //echo "&lt;td&gt;".$result['img']."&lt;/td&gt;";
              echo "&lt;td&gt;".$result['name']."&lt;/td&gt;";
              echo "&lt;td&gt;".$result['description']."&lt;/td&gt;";
              echo "&lt;td&gt;".$result['price']."&lt;/td&gt;";
              echo "&lt;td&gt;".$result['category']."&lt;/td&gt;";
              echo "&lt;td&gt;".$result['sub']."&lt;/td&gt;";
              echo "&lt;/tr&gt;";
          }
      }       ";
  </code></pre>