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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying JPG's in ASP 1

Status
Not open for further replies.

dibbkd

IS-IT--Management
Oct 12, 2002
100
US
I have a database of names, and want to display the employee's picture next the name.

The pictures are in a folder called "images" and files are like james.jpg, betty.jpg, randall.jpg, sally.jpg, etc..

My table has basically two fields, "name" and "picture".
The picture field is basically a text field with the path to the picture, like "\images\sally.jpg".

How can I make the picture show up by the persons name when displaying a bunch of records?
 
You want to use the ASP code to create the HTML sent to the browser.

It sounds like in this case you will be creating HTML <img> tags and setting the "source" property to the path from your database field.
 
Sheco, thanks for the fast reply...

The only thing I've done in ASP is from FrontPage, where you you click on "Insert / Database / Results" and choose the database and go through the wizard.

Do you have an example of some ASP code that would do what you're talking about?

I'm familar with PHP and MySQL, but for this I have to use ASP (because of the server I'm on) and not sure how to do this in ASP...

 
OK, well you know what an HTML <img> tag looks like right?

Here is one from this page:
<img src="/images/logo.gif" alt="Tek-Tips Forums" />

Notice that it has a src property that is the "source" of the image.... the file path to the image.

Soooo... While you are going thru your bunch of records listing the names, you write out an image tag with the appropriate source.

Now suppose your recordset has 3 records like this:
__Name__ ___ImageFilePath___
Howard /images/howardjohnson.jpg
Bill /images/billyB.jpg
Steeve /image/fatso.jpg

The loop for writing the name and images might look something like this in VBScript:

Do While Not myRS.EOF
Response.Write myRS("Name") & "<img src=" & myRS("ImageFilePath") & "> <BR>"
myRS.MoveNext
LooP




 
Well the spacing messed up in my last reply. I was hoping that the 3 records would line up so that you could tell that it is supposed to be a recordset with 3 rows, 2 fields per row.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top