#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    3
    Rep Power
    0

    Need Help Displaying multiple images from access db


    Hello,

    I've been working on this for 2 weeks and finaly decided to quit searching and ask the pros. I'm trying to display

    multiple images in the below code from an access database (2003 but in 2000 format if that makes any difference).

    All parts of this code works perfectly except for displaying the image in the table form. It just displays the LINK

    that I have written in Access under PictureURL as in Http://localhost/sale/images/someimage.gif, and the only reason

    i listed it that way was because i couldn't get d:\inetpub\wwwroot\sale\images\someimage.gif to display at all using

    a seperate little routine that displays all the images thats in the data base but WON'T with the code below. I've tried several different Cfquery name= routines also, like as in very detailed select from where statements but doesn't seem to help any. Im using CF 9 and dreamweaver 7.1 Any help you could give me would be appreciated.
    Natazoo

    <cfif isDefined('URL.StartRow') OR isDefined('Form.StartRow')>
    <cfif isDefined('URL.StartRow')>
    <cfset StartRow=URL.StartRow>
    <cfelse>
    <cfset StartRow=Form.StartRow>
    </cfif>
    <cfelse>
    <cfset StartRow=1>
    </cfif>

    <cfif isDefined('URL.OrderBy') OR isDefined('Form.OrderBy')>
    <cfif isDefined('URL.OrderBy')>
    <cfset OrderBy=URL.OrderBy>
    <cfelse>
    <cfset OrderBy=Form.OrderBy>
    </cfif>
    <cfelse>
    <cfset OrderBy="ID">
    </cfif>

    <cfif isDefined('URL.Direction') OR isDefined('Form.Direction')>
    <cfif isDefined('URL.Direction')>
    <cfset Direction=URL.Direction>
    <cfelse>
    <cfset Direction=Form.Direction>
    </cfif>
    <cfelse>
    <cfset Direction="ASC">
    </cfif>

    <CFQUERY name="GetRecords" dataSource="4Sale" >
    SELECT *
    FROM Normal
    ORDER BY #Variables.OrderBy# #Variables.Direction#
    </CFQUERY>


    <cfset PageName="Normal_List.cfm">
    <cfset TotalRecords=GetRecords.RecordCount>
    <cfset RecordsPerPage=25>
    <cfset NumberOfPages=Ceiling(TotalRecords/RecordsPerPage)>
    <cfset CurrentPageNumber=Ceiling(StartRow/RecordsPerPage)>
    <cfset EndRow=StartRow+RecordsPerPage-1>
    <HTML><HEAD>
    <TITLE>Normal - List Records</TITLE>
    <cfinclude template="Normal_Style.cfm">
    </HEAD>
    <BODY>
    <cfinclude template="Normal_Header.cfm">
    <cfoutput>
    <h3>List Records-Normal</h3>
    <!--- Order by form --->
    <form action="#PageName#" method="post">
    Order By:
    <select name="OrderBy">

    <option value="ID" <cfif OrderBy IS "ID"> selected </cfif>>ID</b></option>

    <option value="PictureURL" <cfif OrderBy IS "PictureURL"> selected

    </cfif>>PictureURL</b></option>

    </select>
    <select name="Direction">
    <option value="ASC" <cfif Direction IS "ASC"> selected </cfif>>Ascending</option>
    <option value="DESC" <cfif Direction IS "DESC"> selected </cfif>>Descending</option>
    </select>
    <input type="submit" value="Go">
    </form>
    </cfoutput>
    <table class="TableBasic">
    <tr>

    <td class="ListTD1"><b>ID</b></td>

    <td class="ListTD1"><b>PictureURL</b></td>

    <td class="ListTD1"><b>Description</b></td>

    <td class="ListTD1"><b>Price</b></td>

    <td class="ListTD1"><b>Sold</b></td>


    <td class="ListTD1">&nbsp; </td>
    <td class="ListTD1">&nbsp;</td>
    </tr>

    <CFOUTPUT query="GetRecords" startrow="#Variables.StartRow#" maxrows="#Variables.RecordsPerPage#">
    <cfif CurrentRow MOD 2 eq 0>
    <cfset TheStyle="ListTD1">
    <cfelse>
    <cfset TheStyle="ListTD2">
    </cfif>

    <tr>

    <td class="#TheStyle#">#ID#</td>
    <!---Right here is where the Image(pictureURL) should be displaying but only thing that shows up in the table is the link that I have in access db listed--->
    <td class="#TheStyle#">#PictureURL#</td>

    <td class="#TheStyle#">#Description#</td>

    <td class="#TheStyle#">#Price#</td>

    <td class="#TheStyle#">#Sold#</td>


    <td class="#TheStyle#"><a href="Normal_Display.cfm?RecordID=#ID#"> Display </a></td>
    <td class="#TheStyle#"><a href="Normal_Edit.cfm?RecordID=#ID#"> Edit </a></td>
    </tr>


    </CFOUTPUT>
    </TABLE>
    <table><tr><td>&nbsp;</td></tr></table>
    <cfif NumberOfPages gt 1>
    <cfoutput>
    <table cellspacing="2" cellpadding="2" border="0">
    <tr>
    <td width="150" align="right" nowrap>
    <cfif CurrentPageNumber gt 1>
    <cfset NextStartRow=Variables.StartRow - RecordsPerPage>
    <a

    href="#PageName#?StartRow=#Variables.NextStartRow#&OrderBy=#Variables.OrderBy#&Direction=#Variables. Direction#">Prev

    ious Page</a>
    </cfif>
    </td>
    <td width="150" nowrap>
    <cfif CurrentPageNumber lt NumberOfPages>
    <cfset NextStartRow=Variables.StartRow + RecordsPerPage>
    <a

    href="#PageName#?StartRow=#Variables.NextStartRow#&OrderBy=#Variables.OrderBy#&Direction=#Variables. Direction#">Next

    Page</a>
    </cfif>
    </td>
    </tr>
    <tr>
    <td width="300" align="center" colspan="2">
    <cfloop index="Counter" from="1" to="#Variables.NumberOfPages#" step="1">
    <cfset

    NextStartRow=(Counter*Variables.RecordsPerPage)-(Variables.RecordsPerPage-1)>
    &nbsp;
    <cfif Counter eq CurrentPageNumber>
    #Counter#
    <cfelse>
    <a

    href="#PageName#?StartRow=#Variables.NextStartRow#&OrderBy=#Variables.OrderBy#&Direction=#Variables. Direction#">#Cou

    nter#</a>
    </cfif>
    </cfloop>
    </td>
    </tr>
    </table>
    </cfoutput>
    </cfif>
    <cfinclude template="Normal_Footer.cfm">
    </BODY>
    </HTML>
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    You need to use the HTML image tag. If you just output the URL to the image all you'll see is the URL.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    3
    Rep Power
    0

    Mabe I don't understand your answer but


    If I were trying to display one image I can understand what your saying I think using the Img scr=pathtoimage.gif but If I have Pictures with a description. price, and if its sold or not,I dont want to write that table out 25 times. The code listed does all of that, and lets you edit it to boot. So in essence, I don't understand what code I need to put in there to display the Image that matchs the description, price, and sold for each of the 25 records per page.

    I appreciate the your help, but its been 8 years since I worked with Coldfusion, and I have forgotten more than I ever learned I beleive. Lol I went from dumb to dumber lol.

    So Thanks for your help, mabe Im just not understanding what your saying there. In other words IF I wasn't trying to display an image in that spot, and it was say another record like a phone number or the like, the code listed would pound it out like its suppose to be listed with no problems, I've just never worked with having to display more than one image before, and I didn't have to use a database to do it, just the img src tag when I needed to, IF I understand what you were refering to.

    Thanks for your help and forgive my ignorance
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    Each image tag you output will be unique to that output row. So if you're outputting 10 records, you'll have 10 images (and 10 prices, descriptions, etc.)

IMN logo majestic logo threadwatch logo seochat tools logo