Hi Nick,

    I'm very interested in what you have here, but I don't think it applies 
because my query is in a component.  But, also, I just don't understand what 
you are doing.  Does #URL.SORT#
 equal to DESC or ASC or what?  Please pardon my not being able to fillow how 
you would use it.  I am curious.  But, on the other hand, I don't think it 
applies.  My problem is trying to display records by numerically sorted account 
numbers and also records that have non-numeric account numbers.  AND, the 
display page is getting it's information from a component as an array.  It's 
making me crazy.  Please let me know if you have any other thoughts though.  I 
very much appreciate your help.

Thanks,
Lewis







-----Original Message-----
From: Eric Nicholas Sweeney <[EMAIL PROTECTED]>
To: cf-newbie <[email protected]>
Sent: Tue, 28 Oct 2008 1:46 pm
Subject: RE: Numerical order of query results



In regards to your sorting... Here's what I do:
When I need to sort a query - I will often pass the sort back to the page in
he URL...
                        <cfif IsDefined("URL.SORT")>
                           ORDER BY #URL.SORT#
URL.Order#
                       <cfelse>
                           ORDER BY LastName
SC
                       </cfif>
That way I can place links in the Column heads and pass it back to the
uery... Helps with sorting ASC and DESC in cases where Alpha/Numerical
orting may be confusing/not obvious to the user - as it allows them to sort
hey data as the wish.
A complete example would look like: (Which also allows the user to search on
he results as well.)
<cfquery name="qryGetEmailSubscribers" datasource="#Application.DSN#"
sername="#Application.username#" password="#Application.password#">
ELECT EmailSubscribers.*
ROM EmailSubscribers
       <cfif IsDefined("Form.data")>
       WHERE #FORM.type# Like <cfqueryparam
fsqltype="cf_sql_varchar" value="%#form.data#%">
       <cfelse>
               <cfif IsDefined("URL.Term") AND #URL.Term#
EQ "">
                   WHERE LastName Like "#URL.Term#%"
                       <cfif IsDefined("URL.SORT")>
                           ORDER BY #URL.SORT#
URL.Order#
                       <cfelse>
                           ORDER BY LastName
SC
                       </cfif>
               <cfelse>
                       <cfif IsDefined("URL.SORT")>
                           ORDER BY #URL.SORT#
URL.Order#
                       <cfelse>
                           ORDER BY LastName
SC
                       </cfif>
               </cfif>
       </cfif>
/cfquery>
Maybe not the most elegant (?) - but it works.
- Nick



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4103
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to