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

Database-driven pictures

Status
Not open for further replies.

coachdan

MIS
Mar 1, 2002
269
US
I am building a database-driven (Access) website in ASP/vbscript for an art gallery. I am trying to store the file path to the artwork in the database (ie. /images/myImage.jpg), but display the picture instead of the path that is stored in the database on the webpage. Is this possible? Does anyone have a link or tutorial on how to do this?

coachdan32

 
Depends on what server side language you are using to retrieve the data... I'm guessing ASP

Retrieve the recordset (oRS) (or whatever you asp chaps call it).. then create an HTML img tag like so

Code:
<img src="<%=oRS('imagePath')%>" alt="alt text - perhaps also from db?" />

I think it's as easy as that

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
I store image path, title (also used as Alt text) and detail description in a db:
Code:
<%
Set ObjCon = Server.CreateObject("ADODB.Connection")
With ObjCon
	.Provider = "MSDASQL"
	.ConnectionString = "DSN=steamdsn;UID=;PWD=;"
	.open()
End with
StrSelBookQuery = "Select PicDetail, PicTitle, PicPath From tblPics Where PicID = " & Request.QueryString("myPic")
Set ObjRS = ObjCon.Execute(StrSelBookQuery)
%>
<body>
<table width="90%" border="0" cellspacing="2" >
  <tr> 
    <td colspan="2" valign="top"> <img src="<%=ObjRS("PicPath") %>" alt="<%=ObjRS("PicTitle")%>"  width="727" height="545" border="0" /></td>
    <td valign="top" width="100%"> <%=ObjRS("PicTitle")%><br/>
     <p> <%=ObjRS("PicDetail")%></p>
  </tr>
 </body>
Don't forget to close your recordset object and your connection object and set them both to Nothing

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

Essex Steam UK for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top