Gossamer Forum
Home : Products : DBMan : Customization :

Age-lt and Age-gt...what the...??!!!

Quote Reply
Age-lt and Age-gt...what the...??!!!
Does anyone know how do I make this work?
I need a search field to search for Ages (between x and y).

I found a few threads about this subject but I couldn't make it work.
I have the $Age field working fine but I can't seem to get the search box working.
This is the code I'm using in the db.cgi file:
if ($in{'Age-gt'}) {
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
my $byear = $year - $in{'Age-gt'} + 1900;
++$day;
++$mon;
($day < 10) and ($day = "0$day");
($mon < 10) and ($mon = "0$mon");
$date = $byear . $mon . $day;
$in{'BirthDate-lt'} = &get_computed_date($date);
}
if ($in{'Age-lt'}) {
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
my $byear = $year - $in{'Age-lt'} + 1899;
++$mon;
($day < 10) and ($day = "0$day");
($mon < 10) and ($mon = "0$mon");
$date = $byear . $mon . $day;
$in{'BirthDate-gt'} = &get_computed_date($date);
}

and this is the code I'm using in the html.pl:
<TR><TD><$font>Age: </FONT></TD><TD> between
<INPUT TYPE="TEXT" NAME="Age-gt" VALUE="$rec{'Age-gt'}" SIZE="2" MAXLENGTH="2"> and
<INPUT TYPE="TEXT" NAME="Age-lt" VALUE="$rec{'Age-lt'}" SIZE="2" MAXLENGTH="2"></TD></TR>

I my .cfg file I've set the Birthdate field using the Universal Date MOD, this is working fine, it give me the right age ($Age) no problem, but I can't get the search function to work. When I try to search I get the "No matching records" message.
What does Age-lt and Age-gt means and how does it work?

Any help would be greatly appreciated.

Thanks!




Quote Reply
Re: Age-lt and Age-gt...what the...??!!! In reply to
What does Age-lt and Age-gt means and how does it work?

lt = lower than
gt = greater than

There are several examples in the FAQ noted below for using range searches. Under the section "Searching" which may help you to find a solution.

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Age-lt and Age-gt...what the...??!!! In reply to
Thank you very much for the reply!

I checked the FAQ but that didn't really help.
Here's the problem.
I do not actually have an "Age" field, the "Age" is calculated using the "Birthdate" field and the date from the server.
Therefore this code:

<INPUT TYPE="TEXT" NAME="Age-gt" VALUE="$rec{'Age-gt'}" SIZE="2" MAXLENGTH="2"> and
<INPUT TYPE="TEXT" NAME="Age-lt" VALUE="$rec{'Age-lt'}" SIZE="2" MAXLENGTH="2">

wouldn't work for me, or would it?
I would appreciate any help!

Thanks.

Quote Reply
Re: Age-lt and Age-gt...what the...??!!! In reply to
In order to search for an age the age would have to be saved to your database. Otherwise you have no means of searching that specific data.

You would need to store the calculated field within your database to be able to to the search.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Age-lt and Age-gt...what the...??!!! In reply to
Thanks again for your reply.
Now the new question is:
How do I save the $Age field in the .db file.

Like I said in my previous message the $Age is calculated from the $Birthdate and unix date fields.
Is there any way I can save the $Age in my .db file so I can later retrieve and search this info?

Thanks again for your help.