Forums
This topic is locked
Interactive sorting of your search results
Posted 26 Feb 2002 00:08:20
1
has voted
26 Feb 2002 00:08:20 Wil Dobson posted:
I created, in my search form, a form pulldown list element which i called 'sortby' and when I submit my search, i replaced my 'order by' SQL statement with the varSortby which had the value of the 'sortby' list.here is my list code (for my dvd database):
<select name="sortby">
<option value="title">Title</option>
<option value="edition">Edition</option>
<option value="rating">Rating</option>
<option value="year">Year</option>
<option value="length">Length</option>
<option value="producer">Producer</option>
<option value="isbn">ISBN</option>
</select>
here is my SQL var:
<%
Dim rsSearch__varSortby
rsSearch__varSortby = "xyz"
if (Request.Form("sortby"



%>
and here is my SQL ORDERBY string:
"' ORDER BY '" + Replace(rsSearch__varSortby, "'", "''"

Rather than the usual "' ORDER BY Title '" or what ever Dreamweaver does for you.
Replies
Replied 26 Feb 2002 11:33:49
26 Feb 2002 11:33:49 Viktor Farcic replied:
Remove ' from ORDER BY string.
" ORDER BY " + Replace(rsSearch__varSortby, "'", "''"
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I created, in my search form, a form pulldown list element which i called 'sortby' and when I submit my search, i replaced my 'order by' SQL statement with the varSortby which had the value of the 'sortby' list.
here is my list code (for my dvd database):
<select name="sortby">
<option value="title">Title</option>
<option value="edition">Edition</option>
<option value="rating">Rating</option>
<option value="year">Year</option>
<option value="length">Length</option>
<option value="producer">Producer</option>
<option value="isbn">ISBN</option>
</select>
here is my SQL var:
<%
Dim rsSearch__varSortby
rsSearch__varSortby = "xyz"
if (Request.Form("sortby"
<> ""
then rsSearch__varSortby = Request.Form("sortby"
%>
and here is my SQL ORDERBY string:
"' ORDER BY '" + Replace(rsSearch__varSortby, "'", "''"
Rather than the usual "' ORDER BY Title '" or what ever Dreamweaver does for you.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Viktor Farcic
TalkZone Manager
" ORDER BY " + Replace(rsSearch__varSortby, "'", "''"

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I created, in my search form, a form pulldown list element which i called 'sortby' and when I submit my search, i replaced my 'order by' SQL statement with the varSortby which had the value of the 'sortby' list.
here is my list code (for my dvd database):
<select name="sortby">
<option value="title">Title</option>
<option value="edition">Edition</option>
<option value="rating">Rating</option>
<option value="year">Year</option>
<option value="length">Length</option>
<option value="producer">Producer</option>
<option value="isbn">ISBN</option>
</select>
here is my SQL var:
<%
Dim rsSearch__varSortby
rsSearch__varSortby = "xyz"
if (Request.Form("sortby"



%>
and here is my SQL ORDERBY string:
"' ORDER BY '" + Replace(rsSearch__varSortby, "'", "''"

Rather than the usual "' ORDER BY Title '" or what ever Dreamweaver does for you.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Viktor Farcic
TalkZone Manager
Replied 26 Feb 2002 16:20:01
26 Feb 2002 16:20:01 Wil Dobson replied:
This wasn't really a question, but a help for those with questions about it.
The ORDER BY string works fine.
I do have a question however about how to number the results. Suppose I pull all records, rather than the first 10... I place a # column. I would like to have the first result show a '1' in the first row, a '2' in the second row and so on.
Anyone know how to do this?
For some reason, my first - previous - next - last navigation hasn't been working lately, so I am forced to pull the entire record. <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
The ORDER BY string works fine.
I do have a question however about how to number the results. Suppose I pull all records, rather than the first 10... I place a # column. I would like to have the first result show a '1' in the first row, a '2' in the second row and so on.
Anyone know how to do this?
For some reason, my first - previous - next - last navigation hasn't been working lately, so I am forced to pull the entire record. <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Replied 27 Feb 2002 13:20:53
27 Feb 2002 13:20:53 Viktor Farcic replied:
When using Repeat Region Server Behavior, UD creates variable Repeat1__index. That where is stored information about record number.
To display it code should look like:
<%=Repeat1__index%> - <%=(RecordsetName.Fields.Item("FielName"
.Value)%>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
This wasn't really a question, but a help for those with questions about it.
The ORDER BY string works fine.
I do have a question however about how to number the results. Suppose I pull all records, rather than the first 10... I place a # column. I would like to have the first result show a '1' in the first row, a '2' in the second row and so on.
Anyone know how to do this?
For some reason, my first - previous - next - last navigation hasn't been working lately, so I am forced to pull the entire record. <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Viktor Farcic
TalkZone Manager
To display it code should look like:
<%=Repeat1__index%> - <%=(RecordsetName.Fields.Item("FielName"

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
This wasn't really a question, but a help for those with questions about it.
The ORDER BY string works fine.
I do have a question however about how to number the results. Suppose I pull all records, rather than the first 10... I place a # column. I would like to have the first result show a '1' in the first row, a '2' in the second row and so on.
Anyone know how to do this?
For some reason, my first - previous - next - last navigation hasn't been working lately, so I am forced to pull the entire record. <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Viktor Farcic
TalkZone Manager
Replied 16 Aug 2002 14:09:40
16 Aug 2002 14:09:40 Kutt Niinepuu replied:
I couldn't quite follow that example. Has anyone done it using PHP? And, would it still work, if I didn't want to associate these "row numbers" with any distinct record, I'd just like to have a ascending column of row numbers before the actual data in the record? So that, when I sort the table by some other field, then those numbers wouldn't go out of order (they would still be ascending from top to bottom).
Thank you.
Less is more1
Thank you.
Less is more1