title: retrieving images from MySQL class and posting them in-page
body: <p>I have a bunch of book covers stored in a column in my book_cache table. I'd like to use the code below to retrieve these cover by doing </p>
  
  <pre><code>&lt;img src="&lt;?php $bcontroller-&gt;getCover($isbn_10); ?&gt;"&gt;
  </code></pre>
  
  <p>However this doesn't work at all....I know how to display each image alone on its own page. I've also been able to create a php script that fetches them from database by calling </p>
  
  <pre><code>&lt;img src="script.php?id=$isbn_10"&gt;
  </code></pre>
  
  <p>however I would prefer to post the images directly from the $bcontroller object class.</p>
  
  <p>Thanks in advance for the help, everyone on here is always very knowledgable.</p>
  
  <pre><code>public function getCover($isbn_10){
      $stmt = $this-&gt;db_conn-&gt;prepare("SELECT cover, mime_type, file_size FROM book_cache WHERE isbn10=?");
      $stmt-&gt;bind_param('s', $isbn_10);
      $stmt-&gt;execute();
      $stmt-&gt;store_result();
      $stmt-&gt;bind_result($cover, $mime, $size);
      while ($stmt-&gt;fetch()) {
      }
      $stmt-&gt;close();
      header("Content-Type: ".$mime);
      echo $cover;
  }
  </code></pre>