PHP Scripts
Retrieve a JPG image from a MySQL database
The easiest way to deal with images is to store just the path in a database, and have the images online.
However, there are occassions when it's necessary to store the JPG as a blob in the database itself.
This simple script retrieves the data and displays as an image.
Let's assume you have a database, with a table called 'pix'
The table needs 4 fields or columns:
id: int(11), Primary, auto-increment
pics: blob
ext: varchar(4)
name: varchar(50)
The include "conn.php" is a standard connect to your database with name, password etc.
Copy the code and below and call it show.php
The useage is:
show.php?n=thumbname, eg, show.php?n=mypic1
Note: to include the retrieved images in a webpage, the useage is:
$tn3="<img src=show.php?tn=$tn";
echo "$tn3>";
$tn=$_GET["n"]; |