Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Getting Started / July 2006



Tip: Looking for answers? Try searching our database.

Help with Counting An Array Recordset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jimmylharrell - 28 Jul 2006 17:09 GMT
I had a friend help me build this but now he's gone and I don't understand
arrays or

coldfusion really. I have an image gallery that works beautifully except that
I want to be

able to add two behaviors to the page. 1.Pagination. 2. Display Record Count.
(I know how

to use the Dreamweaver built in Server Behaviors with Dynamic Tables but this
is a little

different from that b/c he's using arrays to build the table instead. I've
almost go the

pagination working. Except I can't figure how to show the last record. I've
got "First,

Next, & Previous" to work. But the "Last" doesn't. This is the part of the
code that I'm

concerned with as everything else is working.

<cfset CountUp=Count + 10>
    <cfset CountDown=Count - 10>
      <p align="center"><cfif Count gte 10><a


href="gallery.cfm?Count=<cfoutput>#CountDown#</cfoutput>">Previous</a></cfif>&nb
sp;&nbsp;<c

fif ArrayLen(PhotoArray) gt CountUp><a


href="gallery.cfm?Count=<cfoutput>#CountUp#</cfoutput>">Next</a></cfif>&nbsp;&nb
sp;<cfif

ArrayLen(PhotoArray) lt CountUp><a


href="gallery.cfm?Count=<cfoutput>#CountUp##CountDown#</cfoutput>">Last</a></cfi
f>
James74 - 28 Jul 2006 18:31 GMT
You are using a one dimensional array.  Think of it as a column in a table.  So
you can think of it like PhotoArray[1] as the first record in your column.

To display the recordcount, simply display
the length of the array:
#ArrayLen(PhotoArray)#

You are passing the position/record to display in the url:
<cfif isdefined("URL.Count")>
    <cfset k=URL.Count>
    <cfset Count=k>
<cfelse>
    <cfset k=0>
    <cfset Count=0>
</cfif>

I'm not sure why he's doing it the way he is, butif you want to show the
previous record, make a link and include a url parameter named k with the value
of k - 1:

<CFIF Count GT 1>
<CFSET Previous = Count - 1>
<a href="gallery.cfm?Count=#Previous#">Previous</a>
</CFIF>
jimmylharrell - 31 Jul 2006 14:37 GMT
It's not the Previous I'm having a problem. With . It works. It's trying to find the Last Record.
James74 - 31 Jul 2006 16:03 GMT
<CFIF Count EQ ArrayLen(PhotoArray)>

</CFIF>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.