Let’s say I have a file storage database table. This table stores profile picture of a user. How do I display an image stored in a database on webpage, in a specific location. What is the procedure I need to go through, and what PHP functions are used. I know how to send a requested file from a database using HTTP headers. But what I pretty much need is to display an image automatically next to this user’s other textual content. Thanks for any input.
Does not answer my question but thanks for the contribution. How about if size of the image is under 1mb, still not recommended? Why do PHP/MySQL books (published by SitePoint) teach how to store images in a db table if it is not recommended? I mean, they don’t teach you to use <font> tag in HTML because it is deprecated, so they don’t talk about it.
What is the recommended way to do that?
I have a folder for thumbnail images and a folder for full size images - images in the folders have the same names. The image names are then saved in the database.
You will need to query the database something like:
$query = "SELECT image FROM database WHERE username = $username";
$result = mysql_query ( $query ) or die;
// I can not remember the next part but you need to get the result maybe
// something like the next line but you can find tutorials about it!
$row = mysql_array($result);
echo "<img src=\\"path_to_image/".$row['image']."\\">";