Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture from database 1

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
US
Hi guys, i want to create a template like page that will have a placeholder for a picture file. I want to be able to choose one of many pictures from a database and whichever picture I choose will be displayed on the page where the placeholder is. Can someone help me get started on this please :) TIA.
 
Consider just storing the name of the file in the database (for a link)...you don't gain much by storing the actual image as 'blob' in a database...
 
In fact, storing the image as a blob in the database will make things more complicated, as the only way to output this image is either to write it to a file and then display it, or create a frame to display the image (you cannot output anything but the image if your reading the raw binary data and writing it to the page).

-Tarwn

01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
>> you don't gain much by storing the actual image
>> as 'blob' in a database

Yeah, in most cases you lose... performance that is.

-pete
I just can't seem to get back my IntelliSense
 
Ok, that sounds good. Can someone post some code to start me? I don't want someone to do it for me, I'd just like a reference to get started.
 
In your database, have a field called, say, ImageFileName that stores the actual file name of the image; like this:
Code:
-------------
ImageFileName
=============
Image01.gif
Image02.gif
Image03.gif 
-------------
Then, in your ASP page, create the HTML for an image and then interject your filename ...
Code:
<IMG src=&quot;<%MyRecordSet.Fields(&quot;ImageFileName&quot;)%>&quot;>
This extract assumes that:
- You have created a recordset called MyRecordSet and used some SQL to load at least 1 record into it.
- The line of HTML (i.e. the <IMG... bit) above occurs within a section of code that gets the recordset pointing at the appropriate record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top