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

display variable as photo

Status
Not open for further replies.

kevendean

Programmer
Jul 11, 2005
5
US
I have a database that contains image filenames, among other fields. I have pulled the data into a structure (dataStruct) so that I can more easily display it in a dynamically created table. I am trying to display the actual images in the page, rather than just the filenames, using the following code:

<cfif dataStruct.photo is "">
<cfset dataStruct.photo = "No Photo Available">
<cfelse>
<cfset dataStruct.photo = "<img height='50' width='50' src='productphotos/" & trim(dataStruct.photo) & "'>">
</cfif>

However, the output does not display the image or even a broken link, it is just blank. Though if I look at the source code for the output I see the following:

<td><img height='50' width='50' src='productphotos/151-238.jpg'></td>

Can someone help me figure out what is going on here?
 
you're not looking in the right spot would be my guess.

productphotos/151-238.jpg suggests that product photos is a folder higher than your current folder.

in other words if that's not right you may need to adjust your path.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
i am not receiving a broken image icon when i load the page, so it is not simply an issue of the image file being in the wrong place. ColdFusion is not recognizing the string as HTML code and so it is not displaying the image. that's what i need to know how to fix. not the HTML.
 
Though if I look at the source code for the output I see the following:

<td><img height='50' width='50' src='productphotos/151-238.jpg'></td>

ColdFusion is not recognizing the string as HTML code and so it is not displaying the image

want to know a secret?
CF doesn't recognize ANY html, nor does it display any images. it just creates it html. it's the browser that's responsible for getting everything it needs defined by the html. cold fusion simply creates the text required for the browser. if the text(html) is right, the browser will show the image correctly.

so if you're 100% sure that
Code:
<td><img height='50' width='50' src='productphotos/151-238.jpg'></td>
is correct check your css or layout add some text before and after it, see if it shows up.
Code:
<td><cfoutput>XXX#dataStruct.photo#XXX</cfoutput></td>

although it shouldn't matter you can also try using "" instead of ' in the html attribute values.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top