Gossamer Forum
Home : Products : DBMan : Installation :

Range search

Quote Reply
Range search
I just recently downloaded and installed DBMan. Now I'm trying to set up a search and would like to search "less than OR equal to" on one field and "greater than OR equal to" on another field. Can this be done?

Any help would be greatly appreciated!
Quote Reply
Re: Range search In reply to
Yes, it can be done, but you'll have to do a little bit of scripting.

In the code below, substitute FieldName for the actual name of the field in your database.

In db.cgi, sub query, after

local (sortby);

add

Code:
if ($in{'FieldName-gt'}) {
--$in{'FieldName-gt'};
}
if ($in{'FieldName-lt'}) {
++$in{'FieldName-lt'};
}


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





Quote Reply
Re: Range search In reply to
Hey JP,

Works great!! Now I have another question.

I'm searching on 4 fields; Field1 (Jan, Feb, Mar, etc.) and "less than or equal to" Field2 (1, 2, 3, etc.) AND Field3 (Jan, Feb, Mar, etc.) and "greater than or equal to" Field4 (1, 2, 3, etc.)

I'd like to be able to verify that Field2 is less than Field4. If not, the search would result in a failure. Is this possible?
Quote Reply
Re: Range search In reply to
Yes. After the code I gave you, add

Code:
if ($in{'Field-gt'} && $in{'Field-lt'}) {
unless ($in{'Field-gt'} < $in{'Field-lt'}) {
return "invalid range";
}
}

This does not take dates into account, though, so a search for dates from 30 Jan through 5 Feb would fail.


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







[This message has been edited by JPDeni (edited August 29, 1999).]
Quote Reply
Re: Range search In reply to
Hey JP,

One more question, the project I'm working on is an availability database for a group of motels and I'd like to keep this as simple as possible for them.

I created a record for "room type 1" that is available from Sept 1 to Dec 31. Field 1 is month available, field 2 is day available, field 3 month closed and field 4 day closed. The user searches for availability based on these 4 fields. This works fine, however, now I would like to add several fields representing dates for no vacancy (fields 5, 6, 7, and 8 would be month and day no vacancy begins and ends).

Given the above info, if room type 1 is available from 9/1 to 12/31 but unavailable 10/5 to 10/7 and again from 11/15 to 11/19, is it possible to set up a search for this?

I realize this goes way beyond "installation and configuration" and I greatly appreciate your help!
Quote Reply
Re: Range search In reply to
I'll go ahead and post a response so this will be listed as "new" when I come back. I don't know how I would do this, though. I'll think about it this evening as I'm making dinner.


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





Quote Reply
Re: Range search In reply to
Well, I thought about this and I can't figure out how it could be done. Sorry.


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





Quote Reply
Re: Range search In reply to
That's OK, I appreciate your effort. How about this, a room is available from 9/5 to 11/15, however if a user searches for a vacancy from 10/16 to 10/20 the search fails because the departure day (20) is greater than field4 (15). Is it possible to set up the search so that if fields 1 and 2 are less than or equal to and field 3 (departure month) is greater than the user's inquiry, field 4 is ignored. Field 4 would only be checked if field 3 is equal to the inquiry.

I hope this makes sense. I'm trying to set this up without creating multiple duplicate records for the same room type.
Quote Reply
Re: Range search In reply to
I will think about this and get back to you. I'm not sure if I can do it, but I'll give it a shot.


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