At 10:02 AM 09/10/2001 -0500, you wrote:
>Jeffry,
>
>Thanks. The idea was to create Next Record and Previous Record buttons
>on my page. Perhaps it would be simpler to find the next alphabetical
>element, but I just couldn't see it.

You could run the query once, and either cache it or load the whole query 
into a common scope (Application scope perhaps?)
Then set a counter variable (default to 1) and use CFLOOP to loop over the 
particular elements of the query that you need?



>I was thinking was that, if my current record's index was 5, I could get
>the next record by simply adding 1 and the previous record by
>subtracting 1, since the array positions would be numbered sequentially.

  You're on the right track, I think.  I was about to suggest that you 
could use CF5 Query of Query feature, but without an ordered field in the 
result set I'm not sure how you'd do that.



>Maybe there's a common way of doing this that I haven't come across yet.
>
>Regards,
>--John
>
>Jeffry Houser wrote:
> >
> > At 03:53 PM 09/09/2001 -0500, you wrote:
> > >Is there a way to compare the content of a variable with the members of
> > >an array to get the index position of the corresponding array element?
> >
> > >Maybe there's a better way to do this, but this seems like the right
> > >direction. What I have is a query with two columns, one alpha and one
> > >numeric (created as an autonumber).
> > >
> > >For instance, my query would return something like:
> > >
> > >ID      NAME
> > >33      "A Better Way Carpet Cleaning"
> > >12      "Dynamic Accountants"
> > >
> > >Notice that the ID numbers are not in ascending order and have gaps
> > >between them.
> > >
> > >The array would have these two elements in alpha order by NAME. Is there
> > >a way to compare my current URL.ID of 33 to this array, return 0, to
> > >which I could add 1 to get the value, 12, from the next element in the
> > >array?
> >
> >   I'm not quite sure what you want to do.  Either it's very complex and I'm
> > completely or it is very simple and you just got blind-sided looking for
> > the obvious.
> >   A query returns an array of structures, but why can you not loop over the
> > query using either CFLOOP or CFOUTPUT?
> >
> > <CFOUTPUT queryname = "myquery">
> >    #myquery.ID# #myquery.name#
> > </CFOUTPUT>
> >
> >   And it should give you the output you desire no matter what order the IDs
> > are returned in.
> >
> >   I may note that the index of the array in a query object has nothing to
> > do any numerical fields returned by the query, they are sequential.  So, I
> > suppose if you really wanted to (I don't see a point) you could do
> > something like this:
> >
> > <CFLOOP index="temp" from="1" to="arraylen(myquery)">
> >   myquery[temp].ID, myquery[temp].name
> > </CFLOOP>
> >
> >   ( I doubt the code above would work without some massaging, I'm writing
> > from memory )
> >
> >   ???
> >
> > --
> > Jeffry Houser | mailto:[EMAIL PROTECTED]
> > AIM: Reboog711  | ICQ: 5246969 | Fax / Phone: 860-223-7946
> > --
> > I'm looking for a room-mate in the Hartford CT area, starting in September
> > --
> > http://www.instantcoldfusion.com | My Book: Instant ColdFusion 5.0
> > --
> > My Band: Far Cry Fly, Alternative Folk Rock
> > http://www.farcryfly.com | http://www.mp3.com/FarCryFly
> > --
> > My company: DotComIt, LLC
> > database driven web data using ColdFusion
> > --
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to