Please Help!! - Easy Sorting Question

Results 1 to 4 of 4

Thread: Please Help!! - Easy Sorting Question

  1. #1
    Newby Guest

    Default Please Help!! - Easy Sorting Question

    Can any one help or show me a good tutorial?<BR>I have one script that display a row of data from a database and I want to sort the rows. I am I going about it in the the right (correct) manner.<BR><BR>file is called select.asp?sortby=date&orderby=asc<BR>sortby= request.querystring("sortby")<BR>stringorderby = request.querystring("orderby")<BR><BR>then <BR>Select * from temp order by "&#039;&sortby&&#039; &#039;&stringorderby&&#039; <BR>you get my drift<BR>

  2. #2
    Join Date
    Dec 1969

    Default Just VBS coding...

    file is called select.asp?sortby=date&orderby=asc<BR><BR>&#060;%< BR>sortby= request.querystring("sortby")<BR>stringorderby = request.querystring("orderby")<BR><BR>SQL = "SELECT * FROM temp ORDER BY " & sortby & " " & stringorderby <BR>%&#062;<BR><BR>Dunno what all those &#039; marks were doing in there. &#039; doesn&#039;t work in VBScript and you don&#039;t need any &#039; marks in this particular SQL query.

  3. #3
    PM Cooper Guest

    Default RE: Please Help!! - Easy Sorting Question

    You&#039;re on the right track except that the sortby and stringorderby variables should be column names separated by a comma. eg. "ID, Name" Try this:<BR>strSQL = "SELECT * FROM TEMP ORDER BY " & sortby & ", " & stringorderby

  4. #4
    Eddie Campbell Guest

    Default Not quite

    Your answer would be right id StringOrderBy was another field name, but it is just holding Asc or Desc to specify the order in which to sort the data. So Bill&#039;s answer was correct.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts