Forums

This topic is locked

order by in results page

Posted 24 Oct 2002 11:44:24
1
has voted
24 Oct 2002 11:44:24 Wayne Hultum posted:
I have created a search and results page. The search page has 3 search fields (make, model, and type) with the results page showing the results (obviously). If you search one of the fields (eg type) the results page will show only those results.

In the results page I have created order by links so the searcher can order the results Ascendingly or Descendingly using the code below.

a href="resultsequipment.asp?sort=equipment_type&order=ASC">ASC
a href="resultsequipment.asp?sort=equipment_type&order=DESC">DEC
i have put the correct tags in the code

The problem I’m having is that if the searcher orders one of the fields (say sort by model ASC) it puts them in the correct order but it also shows all the other entries in database. Is there a way of only ordering the results that are on the page without showing the rest of the results.

Hope this makes sense and that someone can help.

Replies

Replied 25 Oct 2002 22:07:18
25 Oct 2002 22:07:18 Brent Colflesh replied:
Dear Wayne,
You need the order by links on the results page to pass the params from the search page. Instead of:

a href="resultsequipment.asp?sort=equipment_type&order=ASC">ASC

You need:

a href="resultsequipment.asp?origParam=<?echo $theSearchParam ?>&sort=equipment_type&order=ASC">ASC

Regards,
Brent


Replied 29 Oct 2002 17:33:49
29 Oct 2002 17:33:49 Wayne Hultum replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Dear Wayne,
You need the order by links on the results page to pass the params from the search page. Instead of:

a href="resultsequipment.asp?sort=equipment_type&order=ASC"&gt;ASC

You need:

a href="resultsequipment.asp?origParam=&lt;?echo $theSearchParam ?&gt;&sort=equipment_type&order=ASC"&gt;ASC

Regards,
Brent



<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I'm quite new to this what does that mean
origParam=?echo $theSearchParam ?
do the origParam and theSearchParam need substituting for something in my recordset SQL statement?
I don't think i've setup any in the SQL so will i need to do so.
Replied 30 Oct 2002 17:00:06
30 Oct 2002 17:00:06 Brent Colflesh replied:
Dear Wayne,
On your initial page you choose some parameter to pass to the results page - ex:

&lt;a href="resultsequipment.asp?origParam=whateverWasChosen"&gt;go to results&lt;/a&gt;

Maybe you are doing it via a form or whatever, but you are sending a parameter to the next page.

On the next page, you probably have SQL to the effect:

SELECT *
FROM yourTable
WHERE (make LIKE 'origParam' OR model LIKE 'origParam' OR type LIKE 'origParam')
ORDER BY make

You need to make the ORDER BY dynamic, and pass the original parameter (origParam) back to query when someone chooses one of the order links on the results page.

SELECT *
FROM yourTable
WHERE (make LIKE 'origParam' OR model LIKE 'origParam' OR type LIKE 'origParam')
ORDER BY 'strOrderBy'

So, in UD, under the SQL query in the Advanced screen, you'll have 2 vars:

origParam | abc | $origParam
strOrderBy | make | $sort


Regards,
Brent


Reply to this topic