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

Display Image

Status
Not open for further replies.

adolsun

Programmer
Jan 13, 2004
52
GB
I’m beginner ton ASP.
I’ve been for a while searching but it seems no answer to my question in the past messages.
I’ve created an access db table (product) with these fields: ID, name, price and media (contains a link to the images) I can display all details IID, name and price) on view.asp page but I have no clue how to display the image.

I used:
<%response.write rsnews("media")%>

This displays only the bath of the image (picName.gif).

thanx
 
Whereas this displays only the image of the bath

112298-the%20infamous%20bath%20pot.JPG


:)

Tony
[red]_________________________________________________________________[/red]
Webmaster -
 
Unfortunately neither of them is working, but I tried the following:

<img src= "images/<%=rsnews("media")%>">

And it dose ! Thanks to you all for help and quick response.
 
You didn't state that the images path wasn't already in the graphic source file name, so I didn't include that. What I wrote is basically what you ended up using.

The help you get is only as good as the information you give.

Lee
 
Sorry Lee! you are absolutely right, and your help is highly appreciated.
Ok now, suppose I need to display 2 images belong to one record. For example I've got a product: (book1) and its first image is: (image1.gif) stores on media field and I need to display another image for it. How to store it on db first? Then how to display it?

Note: The images are stored on media folder as well as images folder.

I wish that’s clear enough this time!

Thanks
 
No answer, no problem. What I need now upon my db which has media field. In case if a product dosen't have a picture it dsiplays an empty image (square). How can I avoid showing this empty box. I think I must use IF statement but the question is HOW.
Can anybody help me.
 
Code:
Dim ImageSRC

ImageSRC = RSNews("Media").Value


IF ImageSRC <> "" Then
 Response.Write("<img src=""images/<%=rsnews("media")%>"">")
End IF

 
Thanks mainmast, but as I mentioned earlier I'm new to ASP so what's the correct place for this piece of code. My full page's code is:

Code:
<%@ Language=VBScript%>
<!--#include file="conn.asp" -->
<%
id=request.querystring("id")

selectnewsSQL="select * from products where id="&id
set rsnews=ADO.execute(selectnewsSQL)
%>

<table>
<tr><td>Price:</td></tr>
<tr><td><%response.write rsnews("price")%></td></tr>
<tr><td>

<%
Dim ImageSRC
ImageSRC = RSNews("Media").Value

IF ImageSRC <> "" Then
Response.Write("<img src=""images/<%=rsnews("media")%>"">")
End IF
%>

</td></tr>
</table>

<%
ADO.close
Set ADO=Nothing
%>
 
I see nothing wrong with the code you just posted. Is it giving you a error or something?
 

Yes I'm receiving an error. The error is with this line:
Code:
Response.Write("<img src=""images/<%=rsnews("media")
And the error message is:
Expected ')'

I'm trying on changing the quotation mark or the brakets around but still doesn't work!
 
That string should be:

Code:
Response.Write("<img src=""images/<%=rsnews("media")%>"">")


It is correct in the code you posted in one of your last posts. There isn't even a line with Response.Write("<img src=""images/<%=rsnews("media") in it.
 
I'm writhing it as you said:
Code:
Response.Write("<img src=""images/<%=rsnews("media")%>"">")
And having same error meesage with this line. Any clue!

Thanks mainmast for your patience.
 

Try this:

Code:
Response.Write("<img src=""images/" & rsnews("media") & """>")


A smile is worth a thousand kind words. So smile, it's easy! :)
 
Ooh GREAT ! your are absolutely right, Damber! Thanks a lot Demaber, it's working perfectly now.

Thanks to you all Mainmast and Damber.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top