Display images from database within HTML

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
chaser7016
Forum Commoner
Posts: 34
Joined: Sat Nov 04, 2006 3:22 pm

Display images from database within HTML

Post by chaser7016 »

Can anyone suggest a good how to do this?

I have figure out how to upload photos using mysql and php, placing them into a specific folder. Now I want to display those images onto my html page.

Thanks,
Chaser
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

I have figure out how to upload photos using mysql and php, placing them into a specific folder. Now I want to display those images onto my html page.
Is it that you want both uploading script and then display the images. For this I better suggest you forum search, where in you can find lot of file-uploading scripts. I'm sure that you will find atleast one method matching your requirement.
chaser7016
Forum Commoner
Posts: 34
Joined: Sat Nov 04, 2006 3:22 pm

Post by chaser7016 »

Thanks...sorry for confusion.

I just need the html code and php script that will dispaly in the images in my html page. I got the uploading working and the uploading script uploads to my images folder.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

We've talked about this subject matter quite a bit. What have you found in your research?
chaser7016
Forum Commoner
Posts: 34
Joined: Sat Nov 04, 2006 3:22 pm

Post by chaser7016 »

Nothing yet...Im still looking

thanks to anyone who can point me to a solid up to date how to on this matter. Posting a code suggestion here would rock too!

Cheers, Chaser
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

You've worked out how to upload an image to a server, but you can't figure out how to display an image in HTML?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

chaser7016 wrote:Nothing yet...Im still looking
What were your search terms?
User avatar
dhrosti
Forum Commoner
Posts: 90
Joined: Wed Jan 10, 2007 5:01 am
Location: Leeds, UK

Post by dhrosti »

i think you use <img src="?id=xx" /> to place the image into the document and then set image/jpeg headers (or similar) using $_GET['id'].

Something like...

Code: Select all

<?php
if (isset($_GET['id'])) {
  $imgId = $_GET['id'];
  $sql = "SELECT * FROM table WHERE id=$imgId";
  $query = mysql_query($sql);
  $arr = mysql_fetch_array($query);

  header("content-type: ".$arr['mimeType']);
  echo $arr['fileData'];
}
?>
EDIT: sorry i didnt notice you said the images are in a folder. ignore me.
Post Reply