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.
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.
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
> --
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.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