Gossamer Forum
Home : Products : DBMan : Customization :

Sorting Multiple Fields

Quote Reply
Sorting Multiple Fields
Hello there. I apologize if this is a duplicate Topic (but I did conduct a search of this forum to only find peripheral Topics).

Okay...I am having a problem with our Class Schedule database. The problem is sorting by multiple fields. For instance, I would like to sort records by the Course Number and Subject. What I have is a simplied search form, which allows people to search for the following fields:

1) Academic Area
2) Location
3) Semester
4) Days
5) Meeting Times (BEGIN and END)

I have the records currently sorted by Course Number.

I have created an output table that lists classes by Academic Area. However, when someone just searches for Location, the tables are messy. For instance, I get the "header row" for the first record and then
all courses (not just that subject) below it.

It looks something like this:

Anthropology (ANT)

ANT 101
ANT 101
SLG 101
EGR 101
FRE 102
SLG 102
SLG 102
THR 103

What I would like to have is the following:

The person chooses a location, such as
the Grand Canyon. Their results would be

Grand Canyon

ANT 101
ANT 101
EGR 101
FRE 102
SLG 101
SLG 102
SLG 102
THR 103

If people select a Subject area and then
one or all of the other search options, the records are sorted nicely by the Course Number. The problem is that when they search by one of the search options than Subject area, the results are quite messy.

I was wondering if there is an easy solution to this problem than creating additional sub-routines for different outputs. Before I begin totally tearing apart the script, I was wondering if anyone has some suggestions on how I can modify the program to allow multiple sort fields.


------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Sorting Multiple Fields In reply to
I'm not really sure what you're looking for. In the example you gave, was the search term "Grand Canyon" in the Location field?

Did you see the thread started by BigBritchs in the other DBMan forum? Look at http://www.gossamer-threads.com/scripts/forum/resources/Forum5/HTML/001087.html

That might help.


------------------
JPD





Quote Reply
Re: Sorting Multiple Fields In reply to
Carol,

Yes, Grand Canyon is in the Location field.

I am sorry that I cannot open the database to the public since it is still in the testing stages and the Registrar's Office has made a firm request NOT to post it until it is ready. Sorry...So, I am not able to demo it for you. Frown

I read the Topic you recommended. It did not seem to fully address my problem. Am I correct in assuming that if I take out the sb in my hidden fields for the search form that it will automatically sort by whatever field is chosen?? I will try that.

Although I did come up with a solution when I talked to the user who is converting our database files into the flat file that DBMAN will work with. He is going to sort the database by Subject and Number to be assigned by Record Number. So, I can just specify "1" for sb, which will sort the records both alphabetically by "Subject" and chronologically by "Course Number".

OKAY...I found the part that you were talking about...Yet I would like to find a way to provide a way to "hide" these options and make it seamless for users, not having them choose yet another search option. (Like in a hidden statement...)

OKAY...Tried it and it works. I used the codes from that other Topic and inserted the following codes in my search form sub-routine:

<input type=hidden name="sb" value="5,6">

Thanks, Carol!

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited June 30, 1999).]

[This message has been edited by Eliot (edited June 30, 1999).]

[This message has been edited by Eliot (edited June 30, 1999).]

[This message has been edited by Eliot (edited June 30, 1999).]
Quote Reply
Re: Sorting Multiple Fields In reply to
Okay...So, it is NOT working. The course numbers (CRS) are still sorting very weird. I would like them to be listed in an ascending order (100 - 300). (I spoke with the data manager and he would prefer to have it sorted it at the DBMAN program level than have to go through the extra steps of sorting it in Object Access.)

To see an example of what our results look like, go to:

www.coco.cc.az.us/cgi-bin/example.html

(You will see that the course numbers (CRS) are all out of order.)

In my default.cfg, I have the following configurations:

Code:
SUBJ => [5, 'alpha', 0, 60, 0, '', ''],
CRS => [6, 'numer', 10, 10, 0, '', ''],

In my html.pl, I have the following configurations for the search form:

Code:
<form action="$db_script_url" method="GET">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="sb" value="5,6">
<input type=hidden name="so" value="ascend">

TIA.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited July 12, 1999).]

[This message has been edited by Eliot (edited July 12, 1999).]
Quote Reply
Re: Sorting Multiple Fields In reply to
I'm sorry I didn't answer this before. I must have missed it.

Unless you have made major changes in sub query in db.cgi, I can pretty well guarantee that

<input type=hidden name="sb" value="5,6">

will not give you anything even close to what you want. It probably will not sort on either field.

I do not know of a way to sort by two fields. I referred to changes in sub query above, but I do not know how you would implement those changes.

The only way I can see for you to get the sorting you want is to create another field -- "Sort" -- which would consist of a combination of the "SUBJ" and "CRS" fields. You wouldn't have to display that field, but you could sort by it. And you could have the script automatically create the value of the field, based on the values of the two fields when the record is added.

You might also want to include the "SEC" field in your sorting.



------------------
JPD





Quote Reply
Re: Sorting Multiple Fields In reply to
Thanks, JPDeni.

I will play around with your suggestion and see what I can come up with. Welp, after coaxing the data manager, he came up with a way to sort the database in Object Access.
It seems to be working pretty well.

But for future projects that I won't have the luxury of a data manager or Object Access, it would be nice to identify a way to sort by multiple fields.

Thanks!

Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Sorting Multiple Fields In reply to
If I ever come up with a way to sort by multiple fields, I'll be sure to post it to the forum.


------------------
JPD





Quote Reply
Re: Sorting Multiple Fields In reply to
Thanks, Carol. I'll play around with it, too.

Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us