Displaying images in web pages

from the Artful MySQL Tips List


The simplest way to display images in HTML is directly from the image file, eg ...


<align="center"><img src="name-of-image.png"> </p>

which is one reason it's often recommended that you store such images directly on disk, and store paths to them in the MySQL database, so in PHP you can write ...

<?php
$conn
=mysqli_conect(...);
$res=mysqli_query$conn,... ) or exit( mysqli_error($conn) );
$row=mysqli_fetch_row$res ) or exit( mysqli_error($conn) );;
$picpath=$row[0];
echo 
"<p align="center"><img src='$picpath'> <p>";
?>

Last updated 16 Aug 2024


Return to the Artful MySQL Tips page