-1

Fetching the image(s):

$afbeelding_select = mysql_query("SELECT afbeelding FROM afbeeldingen WHERE sigaren_id = " .$resultaat_fetch_id_sigaren);                  
while ($afbeelding = mysql_fetch_array($afbeelding_select)) 
{
$resultaat_afbeelding = $afbeelding['afbeelding'];
$image = "<img src='data:image;base64,".base64_encode ($resultaat_afbeelding)."'>";
}   

Echo'ing the images:

<?php echo $image;  ?> 

But I'm only getting one image, instead of more. What do I have to change to echo multiple images instead of one?

Kind regards

user3360972
  • 107
  • 2
  • 13
  • You are overwriting the `$image` in every loop. Use array instead. – Sougata Bose Aug 13 '15 at 11:19
  • Concatenate. `$image .= ...`. (Though @b0s3 's suggestion would allow you to have something cleaner and do more things with these images.) –  Aug 13 '15 at 11:19
  • Ooh! it was just adding the point '.'. Thank you very much!! – user3360972 Aug 13 '15 at 11:21
  • If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) [statements](http://php.net/manual/en/pdo.prepared-statements.php) instead, and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Aug 13 '15 at 11:49

1 Answers1

1

you need to concatenate the images otherwise it will be overwritten. change = to .=

$image .= "<img src='data:image;base64,".base64_encode ($resultaat_afbeelding)."'>";
Zain Aftab
  • 703
  • 7
  • 21