View Full Version : Sort by letter
Sep 18th, 2001, 04:37 AM
I was wondering how to go about creating a series of sorting functions for sorting a set of results from a search.
I have links labelled A to Z and a person should be able to click on one of the letter links to sort by that letter. For example, click on the letter Z, and the results beginning with Z come first then all other results in normal alphabetical order.
Can anyone help please?
Sep 19th, 2001, 04:49 AM
What language are you programming this in? Are the links in a database? If you are just using HTML without a database then your best bet is to copy all the links into a program such as word and sort all the links in alphabetical order. Then take each letters collection of links and put that to the top of the list. You can save the list in html to a file such as a.htm Repeat this process for each of the letters and just link to the files.
An example of this would.
If you are using a database then you can get your result by using two different queries such as
SQL = " SELECT name,url FROM links WHERE name like 'z%' ORDER BY name ASC"
- Displays all links beginning with z in alphabetically order
SQL = " SELECT name,url FROM links WHERE name not like 'z%' ORDER BY name ASC"
- Returns all the links aside from z in alphabetical order
All you need to do now is display the output of the first query followed by the output of the second query. These are just two methods but without knowing what language you are using and whether you are using a database I can't really give a better answer. So tell us what you are using and we can help further.
Sep 19th, 2001, 04:52 AM
I am using ASP and connecting to a SQL Server 7 database. The results are shown in an HTML page.
Sep 19th, 2001, 05:19 AM
Well the above will work fine with ASP and SQL Server. :)
You will need to :
Create a database connection
Pass variables between forms (using query string)
Retrieve data from the database.
The idea is that you create a file that reads the letter via the url and then pass this in to the first sql statement stated above. Run the second sql query and display the results from the first query and then the second.
Sep 19th, 2001, 06:24 AM
Thank you for your help!
Sep 19th, 2001, 06:29 AM
No worries! Let us know how you get on.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.