title: Echo out results using MySQL queries to query three tables in a table form
body: <p>I am looking for help. I have 3 tables which I have to query results from. In the table model, I have <code>model_id</code> and <code>model</code>, in the table colour, I have <code>colour_id</code> and <code>colour</code> and in the table availability, I have <code>model_id</code> and <code>colour_id</code>. I have to echo out the results in a table format. The table has to show the model, colour and the availability. In the availability section, if the model is available in a certain colour, it must show/return a yes value and if not show a no. Here is ma current code:</p>
  
  <pre><code>$sql = "SELECT model, colour FROM model, colour";  
     $query = "SELECT * FROM availability";    
  
     $result = mysql_query($sql);
  
     $res =mysql_query($query);
  
   echo "&lt;table border='1'&gt;&lt;trbgcolor='#cccccc'&gt;&lt;td&gt;Model&lt;/td&gt;&lt;td&gt;Colour&lt;/td&gt;&lt;td&gt;Availability&lt;/td&gt;&lt;/tr&gt;";
  
      while($row = mysql_fetch_array($result))
      {
        $model=$row['model'];
        $colour=$row['colour'];
  
        echo "&lt;tr&gt;&lt;td&gt;$model&lt;/td&gt;&lt;td&gt;$colour&lt;/td&gt;";
  
        while($row = mysql_fetch_array($res))
        {
          $avail_id=$row['avail_id'];
          $model_id=$row['model_id'];
          $colour_id=$row['colour_id'];
        }
  
  
        if($res)
        {
          echo "&lt;td&gt;Yes&lt;/td&gt;";
        }
        else
        {
          echo "&lt;td&gt;No&lt;/td&gt;&lt;/tr&gt;";
        }
      } 
  
    echo "&lt;/table&gt;";
  </code></pre>