Show Images
Up
Imagine that you have made a database that contains a record for each employee in a large company or every student in a large school. It's unlikely that anyone would be able to memorize every face, so it would be useful if a photo of the person could appear whenever the person's record is viewed. You cannot store the photos directly in the database but you can use the database to store text that gives the name and location of the pictures on the computer so that the ASP instructions can make the correct photo appear with the displayed record.

For example, let's assume that your web contains and image called image1.jpg which is in the same folder as the page which should display it. You may have noticed that the html instruction to display a picture looks something like this: <img src="image1.jpg"> or, if you want to adjust the dimensions of the picture:  <img src="image1.jpg" width="250" height="60"> Thus, if you have stored the picture names in the database field called text9 for example, and assuming that the dimensions of the picture do not need to be adjusted, you could include this in the HTML code to make the picture appear:

<img src="<%=objRS("text9")%>">

or you could include this in the ASP code:

response.write "<img src=""" & objRS("text9") & """>"

You might be bothered by the 'triple double-quotes' in the line above. A double quote normally marks the beginning or end of a text string in ASP - if you want the text string to CONTAIN a double-quote character you can't use ONE double-quote since this would end the string so instead a PAIR of double-quotes must be used. Since in this case the pair of double-quotes comes just before or just after the double-quote that marks the end or beginning of a text string we end up with a triple double-quote in each case! You might even sometimes see a quadruple double-quote in ASP!!

Previous Up Next