sort-help please

Results 1 to 2 of 2

Thread: sort-help please

  1. #1
    Mona Guest

    Default sort-help please

    Hi guys,<BR> I have to do a sort in my table based on the order of the drop down box.<BR>the drop down box has 5 items in it and depending on the order of the drop down box, the sort varies.<BR><BR>for ex. if the drop down box has id has the first item,name second etc, the sort should be primarily on id, then on name etc.<BR><BR>so, there can be 5*5 combination of items. so does it mean that I have to put 5*5 queries to satisfy all the combination of items, or is there are simpler way of doing it.<BR><BR>please respond.<BR>Thanks,<BR>mona.<BR>

  2. #2
    Join Date
    Dec 1969

    Default So easy it's scary...really!

    Well, for starters, you have to get the order of the dropdown box sent to the server. Easiest way to do that is to make all the options in it be selected before the form posts; probably do it in your "onSubmit" form event handler.<BR><BR> also need to know which one of the items the user selected. In which case you&#039ll have to copy the values into some hidden form control.<BR><BR>Ask more if you need help with this phase of it.<BR><BR>So now we have all the values selected (or all lumped into a hidden form field, with commas separating them, let&#039s say).<BR><BR>So on the ASP page, you&#039ll do:<BR><BR>&#060;%<BR>&nbsp;&nbsp;&nbsp;&nbsp;theL ist = Request.Form("theAppropriateField")<BR>%&#062;<BR> <BR>so what is in that variable, "theList"?<BR><BR>Well you could find out by doing <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Response.Write "theList contains " & theList & "&#060;P&#062;"<BR><BR>But I&#039ll tell you that it contains a string. Using the examples you gave (and adding some of my own), it might contain<BR><BR>"id, name, phone, email, address"<BR><BR>Ummm...wait a sec....<BR><BR>What does an ORDER BY clause in SQL look like???<BR><BR>Yep:<BR><BR>SELECT * FROM table ORDER BY id, name, phone, email, address<BR><BR>So what&#039s the problem? You&#039re done!<BR><BR>&#060;%<BR>query = "SELECT * FROM table ORDER BY " & theList<BR>Set RS = someConnection.Execute(query)<BR>%&#062;<BR><BR><B R>

Posting Permissions

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