Create image DB / php integration

images php coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Fri Dec 28, 2012 5:32 pm

Create image DB / php integration

Postby lip79 » Fri Dec 28, 2012 5:42 pm


I´m trying to make an integration with php and sql.

I have a static webpage (html), with many hyperlinked image thumbs.

I need each thumb to show in a new page with a description associated with the image, and the same image (bigger).

I believe this isnt very hard, but for me is impossible to achieve without help building the database and all the php script needed..

Thanks in advance for the help.

New php-forum User
New php-forum User
Posts: 6
Joined: Fri Jan 04, 2013 1:58 pm

Re: Create image DB / php integration

Postby ayilmaz » Sun Jan 06, 2013 2:34 am

here is an example for you. I havent tried it yet but I think it should work properly.

Arif Yılmaz

Code: Select all

$username = "";
$password = "";
$host = "localhost";
$database = "";
mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error()); mysql_select_db($database) or die("Can not select the database: ".mysql_error());
$id = $_GET['id'];
if(!isset($id) || empty($id) || !is_int($id)){ die("Please select your image!"); }
else{ $query = mysql_query("SELECT * FROM tbl_images WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpg');
echo $content; } ?>

Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest