Gossamer Forum
Home : Products : DBMan : Customization :

Sort Question... sb=ID vs. sb=0

Quote Reply
Sort Question... sb=ID vs. sb=0
JPDeni, you have pointed out to me on several occations that I have (sort by) setup wrong.

I understand that sort by should be set to a field number of the database. However, on my databases if I try to use &sb=0 it doesn't appear to work properly. To get my sort to work I have to use &sb=ID which seems to work fine, why I don't know and I think it is time to find out why.

Here is some setup info:

$db_key = 'ID';
$db_key_track = 1;

%db_def = (
ID => [0, 'numer', 3, 5, 1, '', ''],
Headline => [1, 'alpha', 45, 100, 1, '', ''],
Description => [2, 'alpha', '45x10', 5000, 1, ' ', ''],
LinkTitle => [3, 'alpha', 15, 40, 0, '', ''],
LinkURL => [4, 'alpha', 45, 255, 0, '', '^http://'],
PostTime => [5, 'date', 20, 20, 1, &get_date, ''],
PostedBy => [6, 'alpha', 30, 35, 1, 'Larry', ''],
Verified => [7, 'alpha', 0, 3, 1, 'Yes', 'Yes|No'],
UserID => [8, 'alpha', -2, 15, 0, '', '']
);

Try both sorts on this database and you will see why I use &sb=ID instead of &sb=0. I may have a problem elswhere but I am thinking it has something to do with the 0 (zero) being used for some reason it breaks.

http://www.makeitsimple.com/...ec ords=View+Records

Sort by &sb=0 looks like it works but it breaks sort order by descend and changing it to ascend doesn't help.

Very interesting, basicly I quit working on figuring out why because &sb=ID works. Although, I do think it would be a good idea to figure out why this is happening.

------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: Sort Question... sb=ID vs. sb=0 In reply to
The script looks for a number to be in "sb." If there is no number, it defaults to 0. I just tried using "&sb=fred" and I got the same results as "&sb=ID" and "&sb=0."

What happens when you use "&sb=0"? I don't understand what "looks like it works but it breaks sort order by descend" means.



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





Quote Reply
Re: Sort Question... sb=ID vs. sb=0 In reply to
I think the reason (fred) and (ID) both work is because neither are a valid field number. Sort-by will even accept clinton so it appears as though the search sub just throws out the invalid sort-by term and defauts to the value in $db_key.

When I say &sb=0 breaks sort order it is because you can change sort order to either ascend or desend and it has no affect. Breaking sort order is a bad choice of words because it isn't really broken and the problem lies in sort-by.

Sort-by and sort-order both work properly with any field number that is in the db_def other than 0(zero) being used for sort-by.

There is something going on with using sort-by = zero, just haven't put my finger on it yet.

------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: Sort Question... sb=ID vs. sb=0 In reply to
It seems to work with so=ascend, too. I just tried it and got

ISP from hell day! Apr-01-1999 15:58:16
Trying to have a life! Wink Apr-04-1999 22:03:15
Just Slaving away in the background Apr-08-1999 06:11:56
Case Cooling Update Apr-10-1999 06:13:41
Yes I am still alive... Apr-17-1999 05:23:45

What's the earliest record you have?

(I'm really not trying to be argumentative, but I just can't seem to replicate the problem.)



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





Quote Reply
Re: Sort Question... sb=ID vs. sb=0 In reply to
Ahhh, you are on a different database. Try the one that is in the first post of this thread.

This has me going now, if it works in the blub database I wonder what I have set wrong in the Hardware and Game news databases.

Hmmmmm

------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: Sort Question... sb=ID vs. sb=0 In reply to
Ah, I see. I was going by the same database. I didn't notice the different URL.

Is your field 0 the date/time field? If so, is the datatype set to "date"?

I think it must have something to do with your .cfg file.



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





Quote Reply
Re: Sort Question... sb=ID vs. sb=0 In reply to
Carol... refer to post one! LOL Wink hehehe

I think it has all of the config info you are asking for.



------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: Sort Question... sb=ID vs. sb=0 In reply to
Sorry. I'm getting punchy. I think I've been online too long! Smile

It doesn't make any sense to me. Maybe I'll be able to figure it out later.


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





Quote Reply
Re: Sort Question... sb=ID vs. sb=0 In reply to
Don't worry about this one it isn't a problem for me I work around it.

Although I think it would be interesting to find out why. It may be a minor bug that could pop up down the road for someone else.

The new (mod) for long/short display is what I want to get working.

By the way if you don't mind I would like to ask you a few questions in email regarding another mod that I have. This one could be very useful to a lot of people but I don't want to talk about here yet.

You will have to email me because I lost your email addy.

Cheers!

------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com

Quote Reply
Re: Sort Question... sb=ID vs. sb=0 In reply to
I guess this did come up already! <grin>

I was able to make it work (at least with my field names) by using:

Code:
<SELECT NAME="sb">
<OPTION>---
~; for (my $i =0; $i <= $#db_cols; $i++) { print qq~<OPTION VALUE="$db_cols[$i]">$db_cols[$i]</OPTION>\n~ if ($db_form_len{$db_cols[$i]} >= 0); } print qq~
</SELECT>
Sort Order:
<SELECT NAME="so">
<OPTION VALUE="ascend">Ascending
<OPTION VALUE="descend">Descending
</SELECT>

This was the automatically generating sort by uses the same name for both the display and the option.

Of course, you could always just fill in the HTML code without autogenerating it each time as well.

Thanks!
Dave