Are there alternative methods to outputting images from a database in PHP besides using <img src=bild.php?id=1>?
When outputting images from a database in PHP, using the <img src=bild.php?id=1> method is a common approach. However, an alternative method is to base64 encode the image data and embed it directly into the HTML using the data URI scheme. This can be achieved by fetching the image data from the database, encoding it using base64_encode(), and then embedding it in the HTML img tag.
<?php
// Connect to database and fetch image data
$imageData = // Fetch image data from database
// Encode image data to base64
$base64Image = base64_encode($imageData);
// Output the image directly in the HTML using data URI scheme
echo '<img src="data:image/jpeg;base64,' . $base64Image . '" />';
?>