title: How do I make the image in the MySQL table alter based on the id
body: <p>I have a table with an "id" that automatically increment each time a new entry is added to the table. In the same table, I also store images. </p>
  
  <p>Regardless of the id incrementing the image is always the same.</p>
  
  <p>I would like the images to change based on the "id". How do I achieve this?
  Find below my code to file: displayImage.php:</p>
  
  <pre><code>$link = mysql_connect("localhost", "root", "") or die("Could not connect: " . mysql_error());
  
  // select our database
  mysql_select_db("flightSched") or die(mysql_error());
  
  // get the image from the db
  $sql = "SELECT image FROM flightSched";
  
  // the result of the query
  $result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
  
  // set the header for the image
  header("Content-type: image/jpeg");
  echo mysql_result($result,1);
  
  // close the db link
  mysql_close($link);
  </code></pre>
  
  <p>And the code with the incrementing "id"</p>
  
  <pre><code>$result = mysql_query("SELECT id, flightNo, airline, origin, arrivalTime, status 
                         FROM flightSched ") 
      or die(mysql_error());  
  
      $variable= 'id=basicBoard';
      //echo $variable;
  
  
      echo "&lt;table border='1' id='customers'&gt;";
      echo "&lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;Flight No&lt;/th&gt; &lt;th&gt;Airline&lt;/th&gt; &lt;th&gt;Origin&lt;/th&gt; &lt;th&gt;Arrival&lt;/th&gt; &lt;th&gt;Status&lt;/th&gt; ";
      // keeps getting the next row until there are no more to get
      while($row = mysql_fetch_array( $result )) {
          // Print out the contents of each row into a table
          echo "&lt;tr " . $variable . "&gt;&lt;td&gt;"; 
  
          echo '&lt;img src="displayImage.php?id=' . $row['id'] . ' " width="40" height="40" &gt;';
          echo "&lt;/td&gt;&lt;td&gt;"; 
          echo $row['flightNo'];
          echo "&lt;/td&gt;&lt;td&gt;"; 
          echo $row['airline'];
          echo "&lt;/td&gt;&lt;td&gt;"; 
          echo $row['origin'] . $row['id'];
          echo "&lt;/td&gt;&lt;td&gt;"; 
          echo $row['arrivalTime'];
          echo "&lt;/td&gt;&lt;td&gt;"; 
          echo $row['status'];
          echo "&lt;/td&gt;&lt;/tr&gt;"; 
  
          if ($variable == 'id=basicBoard')
              {
              $variable = 'class=alt';
              //echo $variable;
              } 
          elseif ($variable == 'class=alt')
              {
              $variable = 'id=basicBoard';
              //echo $variable;
              } 
          } 
  
          echo "&lt;/table&gt; &lt;br/&gt; &lt;br/&gt;";
  </code></pre>
  
  <p>Looking forward to your reply.
  Any help is greatly appreciated!</p>