Gossamer Forum
Home : Products : DBMan : Customization :

Greater than or less than..

Quote Reply
Greater than or less than..
Looking to do a range of prices in one pull down box.

Currently I use two pull down boxes to get the job done. Code is as follows:

<TR>
<TD align="Right" valign="TOP"><$font>Minimum Price:</FONT>
</TD>
<TD valign="TOP">
<SELECT name="Price-gt" value="$rec{'Price'}">
<OPTION value="50,000">50,000
<OPTION value="100,000">100,000
<OPTION value="150,000">150,000
<OPTION value="200,000">200,000
<OPTION value="200,000">250,000
<OPTION value="300,000">300,000
<OPTION value="350,000">350,000
<OPTION value="400,000">400,000
<OPTION value="450,000">450,000
<OPTION value="500,000">500,000
<OPTION value="550,000">550,000
<OPTION value="600,000">600,000
</SELECT>
</TD>
</TR>
<TR>
<TD align="Right" valign="TOP"><$font>Maximum Price:</FONT>
</TD>
<TD valign="TOP">
<SELECT name="Price-lt" value="$rec{'Price'}">
<OPTION value="50,000">50,000
<OPTION selected value="100,000">100,000
<OPTION value="150,000">150,000
<OPTION value="200,000">200,000
<OPTION value="200,000">250,000
<OPTION value="300,000">300,000
<OPTION value="350,000">350,000
<OPTION value="400,000">400,000
<OPTION value="450,000">450,000
<OPTION value="500,000">500,000
<OPTION value="550,000">550,000
<OPTION value="600,000">600,000
</SELECT>
</TD>
</TR>


What I'm looking for is using only on pull down box that will have the range like:

<OPTION value="450,000 - 499,000">450,000 - 499,000

Any help would be appreciated.

Thanks in Advance
Fred
Quote Reply
Re: Greater than or less than.. In reply to
You might be able to do it, but I'm wondering about the commas in the numbers. How are your prices entered in the fields? (I'm just not sure that DBMan will recognize a number with a comma as a number that will sort correctly and do the correct comparisons.) That doesn't mean you can't have commas in what the user sees, but I'm wondering about having them in the actual search term.

Anyway, there is a way you can send a range to the script for a search. Let's call the select field "PriceRange." Assuming that your inputs are all in the form of

450,000 - 499,000

with a "space hyphen space" between them, you can add some code to sub query in db.cgi to break it up for you.

After

local (%sortby);

add

Code:
if ($in{'PriceRange'}) {
($in{'Price-gt'},$in{'Price-lt'}) = split(" - ",$in{'PriceRange'});
}

Assuming that the commas will work in the -gt and -lt comparisons, this will give you (using the example above) items with prices from 450,001 through 498,999.

If you want your sort to include the numbers on each end of the range, change it to

<OPTION value="449,999 - 499,001">450,000 - 499,000

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







[This message has been edited by JPDeni (edited May 01, 1999).]
Quote Reply
Re: Greater than or less than.. In reply to
JPD...
Thanks. Appreicated that. Do I put that int the DB.cgi and where?

Thanks for your help in advance.

Fred
Quote Reply
Re: Greater than or less than.. In reply to
Yes, put it in db.cgi, sub query, just after

local (%sortby);

(I just saw that I didn't do my UBB coding correctly. I'll fix that.)


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