• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

Reading and displaying images from an access database in dreamweaver mx using Coldfusion mx

I have an access database with about 400 images, these images are all stored in 1 folder call images in the root folder. with the code I have all the images are appearing on the same page, how do you make them appear one by one?
heres my code.....

<CFQUERY NAME="sel_image" DATASOURCE="databaseproject.mdb">  
SELECT * FROM Tattoos</CFQUERY>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<CFOUTPUT QUERY="sel_image">  
<IMG SRC="images/#image#"><BR></CFOUTPUT>
<html>
</body>
</html>
0
clonmelog
Asked:
clonmelog
1 Solution
 
kkhippleCommented:
have a look at your earlier question that was posted:

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21369958.html
0
 
mrichmonCommented:
You have to do some sort of paging.  The code below shows 10 images per page.  If you want one per page then change the rowsperpage.

Put this at the top of the page
<!--- ------------------------------- --->
<cfquery NAME="sel_image" DATASOURCE="databaseproject.mdb">
SELECT * FROM Tattoos
</cfquery>

<!--- Set up defaults so we can display results in Next-N interface --->
     <cfparam name="URL.StartRow" type="numeric" default="1">
     <cfparam name="URL.ShowAll" type="boolean" default="No">
     <cfset TotalRows = GetItems.RecordCount>
     <cfif URL.ShowAll>
          <cfset RowsPerPage = TotalRows>
     <cfelse>
          <cfset RowsPerPage = 10>
     </cfif>
     <cfset EndRow = Min(StartRow + RowsPerPage - 1, TotalRows)>
     <!--- Set up the start row for next and back buttons --->
     <cfset NextStart = EndRow + 1>
     <cfset BackStart = StartRow - RowsPerPage>
<!--- ------------------------------- --->


Put this in the page where you want to display the records
<!--- ------------------------------- --->
<cfloop query="sel_image" startrow="#StartRow#" endrow="#EndRow#">
<!--- code to display each record goes here --->
<IMG SRC="images/#image#"><br>
</cfloop>
<!--- ------------------------------- --->

Put this at the bottom of the page
<!--- ------------------------------- --->
<cfset Pagenum = 1>
<cfif TotalRows GT 0>Page</cfif>
<cfloop index="Row" from="1" to="#TotalRows#" step="#RowsPerPage#">
     <!--- If Pagenum is current page then show without link --->
     <cfif Row EQ StartRow>
          <b>#Pagenum#</b>
     <cfelse>
          <a href="Display.cfm?CatID=#CatID#&StartRow=#Row#">#Pagenum#</a>
     </cfif>
     <cfset Pagenum = Pagenum + 1>
</cfloop>
Displaying <b><cfif TotalRows GT 0>#StartRow#<cfelse>0</cfif></b> to <b>#EndRow#</b> of <b>#TotalRows#</b> Items
<!--- ------------------------------- --->
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now