Gossamer Forum
Home : Products : DBMan : Customization :

Searching "Less/Greater" Than Ranges

Quote Reply
Searching "Less/Greater" Than Ranges
I'm running a test on trying to search a prise range that includes a minimum and maximum price paramaters.

Here's the link:
http://www.seekhomes.com/FindHomes.html
In the Price Range areas I use 2 pick lists for the amounts.

For some reason this search sometimes works ok and sometimes returns a "no matching records found" message even if there are matches.

What is it I'm doing wrong? Can anyone look at the FindHome.html code and see what I need to modify.

Help!
Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
I was playing around with it and then I got an error. You must be uploading or something. Smile

I'm wondering if the problem could be related to the commas. I'm not sure, but that might be a problem.

What is the field type set to for the Price field?

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





Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
It's setup as a number. But I have tried to set it up as alpha and got the same error.

BTW - I was uploading the .cfg file when you probably got that error. ;-)

I'll change it to alpha and you can look at it and see what happens.

Also, I narrowed down the problem, any searches bellow the 1,000,000 range work fine, the moment Max Price is above 1,000,000 things go haywire.
Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
The field type really does need to be set to "numer."

I know it will be a pain, but why don't you give it a try taking out the commas in the prices? You can leave your select fields basically the same, at least as far as users would see. Just take out the commas in the "Value" part of the select fields and in the records. If you want to show commas in the prices when you display the record, we can do that, too, but right now let's get the searches working right.


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





Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
Can you give me an example of a search that you know should work but doesn't?


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





Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
Here's a sample search:

Price Range:
Min Price = $800,000
Max Price = $4,000,000

Should return several hits, instead it reports back "no matching records".

Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
I made the changes and created a search page with the new amounts w/o the commas.
It works now:
http://www.seekhomes.com/FindHomesA.html

Now how do I display the commas in the results? You mentioned there might be a way.

Thanks a million.
Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
Me and my big mouth! Wink

Hang on for a sec while I play with some formatting commands. (I'm still pretty new at this.)

I think I'm gonna have to go look at some things first. I'll be back.


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





Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
I looked around and found this code that will insert commas but I have no idea where I should add it. (program and location w/in the program)

sub commify {
local $_ = shift;
$_ = sprintf ("%.2f", $_); # 2 decimal points.
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
# insert commas return $_;
}

Sorry for bugging you with questions.
But your help is greatly appreciated.

Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
It's really no problem. I should be learning this stuff anyway. Smile

My local guru came up with a similar code.
Code:
1 while $rec{'Price'} =~ s/(\d)(\d{3})\b/$1,$2/;

You don't have to worry about decimals, so you don't need part of the "commify" subroutine you posted.

Put this in html_record, before you start printing -- that is, before the first print qq statement.

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





Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
I added that line of code to the html.pl file under the html_record section right before the first "print qq|" statement and it's not working.

Link: http://www.seekhomes.com/FindHomesA.html

Any ideas?
Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
You have the line between

my (%rec) = @_;

and

print qq|

right? (There's also the "autogenerate" line in there, but you're not using autogenerate so that wouldn't be a factor.)

You might try it just before you print out the price.

Code:
|;
1 while $rec{'Price'} =~ s/(\d)(\d{3})\b/$1,$2/;
print qq|$rec{'Price'}

I did test the code in a little Perl script on my home computer, so I know that Perl understands the line.

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





Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
I must be doing something wrong. Here's the section of html.pl where I added your code:

sub html_record {
my (%rec) = @_;
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';

# CB 5/7/1999 - Formats Amounts with commas
---------------------------------------------
1 while $rec{'Price'} =~ s/(\d)(\d{3})\b/$1,$2/;
print qq|$rec{'Price'}

After this follows the code for the table.

Would it be easier if I e-mailed you the html.pl file to see what I'm doing wrong?

Thanks. My e-mail is bogdan@ezfindit.com.
Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
If you're not getting errors -- cgi errors or 500 errors, I'd rather try to work with you here. If need be, you can put your html.pl script in a web-accessible directory where I can see it. But for now, lets try it here.

Let's try

my (%rec) = @_;

1 while $rec{'Price'} =~ s/(\d)(\d{3})\b/$1,$2/;

($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';

print qq|[code for your table]|;


If that doesn't work, we'll take a look at your html.pl script. Deal? Smile


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





Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
Deal!

I tried the last suggestion you made and still no go.

I created a test folder for the html.pl file. You can find the file at: "www.seekhomes.com/test/html.pl"

The testing search page is located at: "www.seekhomes.com/FindHomesA.html".

I don't know why it's not working.

Thank you for your help. I really appreciate the time you've spent in trying to find a solution to my problem.

Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
I didn't realize you were autogenerating your display.

Move

1 while $rec{'Price'} =~ s/(\d)(\d{3})\b/$1,$2/;

to be above

($db_auto_generate and print &build_html_record(%rec) and return);

The trouble you've been having is that, since you're autogenerating, the script never gets to the "commify" line. I'll bet it works just fine if you switch the "autogenerate" line and the "commify" line.


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





Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
EUREKA!! It works perfectly now!

Thank you very, very much.
Quote Reply
Re: Searching "Less/Greater" Than Ranges In reply to
Well, if nothing else, I'm persistent!

I'm so glad that it worked for you. And I learned a lot too.


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