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!

SQL & Cold Fusion ¦ outputting data with an image 1

Status
Not open for further replies.

tsp1lrk

IS-IT--Management
May 30, 2001
103
US
Hi All!

Let me first say that this forum has been most helpful in my moments of rage when I'm tearing my hair out of my head trying to figure things out! So thank you for all your support!

My problem: I know this is not difficult but I'm struggling with the best method.

I have a SQL database, I'm using Cold Fusion. All I want to do is retrieve the data with each record and show an image along with it, a thumbnail next to it-- I hear the best way is to put the path in the SQL table to the image-- Can anyone show me an example of how to do this? I already have a database and tables and what not, I'm assuming I add another field called "pic" or "img" or something- then put a path in there to my images-- but I'm confused on how to call this out of the database-- my query as of right now is:

<CFQUERY datasource=&quot;MYDSN&quot; NAME=&quot;GetDocs&quot;>

SELECT *
FROM tblTechCat a, tblTechContent b
WHERE a.strDptID = b.strDptIDfk
ORDER BY strDptName, strDptIDfk
</CFQUERY>


How do I retrieve data as well as images using a SQL database and Cold Fusion?? HELP!

Lisa
 
Lisa,

There is no magic in SQL that I am aware of. I think you will want to use ColdFusion to pull the data (using CFQUERY tags). That query record set must contain an address that points to the image you want to display. You then use ColdFusion to fill in the value of the SRC attribute of an IMG tag in HTML to display the image.

Good Luck,
Fran
 
I do this with several sites. I usually have a field in a table for the image file name (image1.jpg, for example). Then I make sure all of the images are in a specific folder (ImageFolder, for example). Then in my cfquery, I have it select the image name from the table, and I have it output into a html image tag.

<CFQUERY datasource=&quot;MYDSN&quot; NAME=&quot;GetDocs&quot;>
SELECT Record1, Record2, Record3, Image
FROM tblTechCat a, tblTechContent b
WHERE a.strDptID = b.strDptIDfk
ORDER BY strDptName, strDptIDfk
</CFQUERY>
<cfoutput>
<img src=&quot;whateverdirectory/ImageFolder/#Image#>
</cfoutput>
This would output in the HTML as:
<img src=&quot;whateverdirectory/ImageFolder/image1.jpg>

Hope this helps,

Eric
 
Thanks-- I got it working! I love this forum!

Lisa
 
I need to output the image from SQL server with ColdFusion interface too. However, my problem is that instead of storing the image's path in the field, I store the actual image in the field (no other option for me). Anyone know how I could output the image with ColdFusion? Thanks a million!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top