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

images continued

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Thanks for those who told me that to store an image in a database to use the pathway, which works. However, if a record does not have an associated picture then the standard little red cross in a white box appears which signifies no picture. This looks bad. How do I get it to display a picture only if there is one associated with a record? If there is no associated picture then nothing should be displayed.

Currently the code is <img src=images/<%=rs(
 
What about putting an <%if ....... then%>
<img src=images/<%=rs(........)%>
<%end if%>

where the first set of ....... is a test to see if there is a picture associated with the record.

Hope this helps. s-)
 
I wouldn't bother storing the path to your images in your database at all, as usually there is no need... (The Hard Way)

If your images relate to certain products (or whatever), rename your images to include the ID number of the product, eg: 65image.jpg (The Easy Way)

Therefore your code would look like this:

[tt]Response.Write &quot;<img src='images/products/&quot; & oRS(&quot;ProductID&quot;) & &quot;image.jpg>&quot;[/tt]

To stop the display of a red cross where no image exists, make a new field in your products table called something like intNoOfImages, then you can test whether an image exists or not before attempting to display it.

Hope this helps.

 
All you would have to do is see if the length of the variable is greater than 0:

<% if len(ImgName) > 0 then %>
<img name=&quot;<%= ImgName %>&quot;>
<% end if %>

Of course, I'd advise on putting in images into the database in another way (storing the image filename but not the actual image), but that requires an ASP plugin like ASPUpload in order to get ASP to handle file transfers. Otherwise, I'd say to make something using Cold Fusion.

Is the data on the database dynamic or is it simply hardcoded into there? In other words, is there an application that puts the info into it? [sig]<p> <br><a href=mailto:aberman@thebiz.net>aberman@thebiz.net</a><br><a href= > </a><br>Database web programmer and developer, fueled by peach snapple and mochas.[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top