title: Displaying images retrieved from database using PHP
body: <p>I would like to know how to display an image stored in a database inside of a particular <code>div</code> using PHP code?</p>
  
  <p>The code I used looks like that:</p>
  
  <pre><code>&lt;form method="post"&gt;
  &lt;input type="button" name="show" value="show"/&gt;&lt;br/&gt;
  &lt;input type="image" id="image_show" name="img" value="img"/&gt;
  &lt;/post&gt;
  
  if(@$_POST['show'])
      {
          $sql="select imageData form images ORDER BY DESC";
          $result=mysql_query($sql) or die('invalid query'.mysql_error());
          //set header
          header("Content-type:image/png");
          echo mysql_result($result,0);
          while( $row = mysql_fetch_row( $result ) )
          {
              echo "&lt;img src='".$row[0]."'/&gt;";
              }
          }
  </code></pre>
  
  <p>But it does not work. How can I solve this task?</p>