title: PHP image display from mysql from different tables
body: <p>I am creating a used car website for a class. I have a mysql database that has two tables. One for the car details and one table for car photos. I am trying to display 1 single photo of the car next to some details (like you see on cars.com) but I am struggling. The car id is one one table and the "ext_1" in on another table.</p>
  
  <pre><code>&lt;?php
  
  $page_title = "List cars";
  
  require_once ('includes/header.php');
  require_once('includes/database.php');
  
  //select statement
  $sql = "SELECT * FROM inventory_tbl, inventory_photos_tbl";
  //execute the query
  $query = $conn-&gt;query($sql);
  
  //Handle selection errors
  if (!$query) {
  $errno = $conn-&gt;errno;
  $errmsg = $conn-&gt;error;
  echo "Selection failed with: ($errno) $errmsg&lt;br/&gt;\n";
  $conn-&gt;close();
  //require_once ('includes/footer.php');
  exit;
  }
  //display results in a table
  ?&gt;
  &lt;h2&gt;Inventory&lt;/h2&gt;
  
  &lt;table border="1px solid" border="collapse" align ="center" height='300'  width='750' &gt;
  &lt;tr&gt;&lt;center&gt;
              &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Year&lt;/th&gt;
      &lt;th&gt;Make&lt;/th&gt;
      &lt;th&gt;Model&lt;/th&gt;
      &lt;th&gt;Mileage&lt;/th&gt;
              &lt;th&gt;Price&lt;/td&gt;
      &lt;th&gt;Details&lt;/th&gt;
  &lt;/center&gt;
  &lt;/tr&gt;
  
  &lt;?php
  //insert a row into the table for each row of data
      while (($row = $query-&gt;fetch_assoc()) !==NULL){
          echo "&lt;tr&gt;";
          echo "&lt;td&gt;&lt;img src =" .$row['id']. $row['ext_1']. " width = 100     height = 100&gt;&lt;/td&gt;";
          echo "&lt;td&gt;", $row['year'], "&lt;/td&gt;";
          echo "&lt;td&gt;", $row['make'], "&lt;/td&gt;";
          echo "&lt;td&gt;", $row['model'], "&lt;/td&gt;";
          echo "&lt;td&gt;", number_format($row['mileage']), "&lt;/td&gt;";
          echo "&lt;td&gt;","$", number_format($row['price']), "&lt;/td&gt;";
          echo "&lt;td&gt;&lt;a href='cardetails.php?id=", $row['id'],"'&gt;View Details&lt;/td&gt;";
          echo "&lt;/tr&gt;";
      }
  ?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;?php
  // clean up resultsets when we're done with them!
  $query-&gt;close();
  
  // close the connection.
  $conn-&gt;close();
  
  //include the footer
  require_once ('includes/footer.php');
  </code></pre>