I have a search results page where I am using the column headers as way to 
sort. Each time you click to header, it runs the query again and appends the 
URL to something like searchresults.cfm?SortBy=Price.

However, once you sort by Column Header, it returns ALL the rows, not just the 
results of the intial search (where you might be filtering by Price, Category, 
Size, etc). Below is the relevant code:

<cfparam name="SortBy" default="Designer">

<CFQUERY NAME="search_results" DATASOURCE="DB">
SELECT P.ProdID, P.Designer, P.DressSize, P.Price, C.Category, C.CatID   
FROM Products P
JOIN Category C
ON P.CatID = C.CatID
WHERE 0=0

<CFIF FORM.Designer IS NOT "">
    AND Designer LIKE '%#FORM.Designer#%'
</CFIF>

<CFIF FORM.DressSize IS NOT "">
    AND DressSize LIKE '%#FORM.DressSize#%'
</CFIF>

<CFIF FORM.Price IS NOT "">
    AND Price <= #FORM.Price#
</CFIF>

<CFIF FORM.CatID IS NOT "">
    AND C.CatID = #FORM.CatID#
</CFIF>
ORDER BY #sortBy#
</CFQUERY>


<tr>
<td><a href="searchresults.cfm?SortBy=Category">Category</a>td>
<td><a href="searchresults.cfm?SortBy=Designer">Designer</a></td>
<td><a href="searchresults.cfm?SortBy=DressSize">Size</a></td>
</tr>

I know I'm missing something simple...

Thanks
Rick
        


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250785
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to