title: Display multiple images using watermark in PHP
body: <p>I want to add watermark on multiple images and display them on browser. Here is my piece of code:</p>
  
  <pre><code>&lt;?php
  include('admin/connect.php');
  $q = mysql_query("select * from ring");
  while($row=mysql_fetch_array($q)){  
      $img = 'admin/'.$row['Image'];
      $stamp = imagecreatefrompng('admin/image/watermark.png');
      $im = imagecreatefromjpeg($img);
      $marge_right= 20;
      $marge_bottom = 50;
      $sx = imagesx($stamp);
      $sy = imagesy($stamp);
      imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
      header('Content-type: image/png');
      imagepng($im);
      imagedestroy($im);
  }
  ?&gt;
  </code></pre>
  
  <p>I have used <code>header('Content-type: image/png');</code> in my code due to which I am not able to display all the images.
  Here I am fetching images from database and then adding watermark on it but it will be better if anyone of you can help me to add watermark first and then save it in database.
  Thanks in advance.</p>