Gossamer Forum
Home : Products : DBMan : Customization :

Ago search

Quote Reply
Ago search
hi again,
I would like to ask if it is possible to do the following search.
there are two fields called "agefrom" and "ageto". User A can enter 16 in "agefrom" field and 25 in "ageto" field in the record. So,when people search for 18 in an age field. User A record show up
Any one could help me ?
THank here first.
Smile
Quote Reply
Re: Ago search In reply to
Didn't I answer this in http://www.gossamer-threads.com/...m12/HTML/002754.html ? Did you have problems with what I gave you?


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






Quote Reply
Re: Ago search In reply to
yeah.....that works prefect (thanks again here)...
however,this time i would like to do that works the other way around. Instead of user entering their birth and people using "range" search for the user's age,there are two fields called "agefrom" and "ageto" now. User A can enter 16 in "agefrom" field and 25 in "ageto" field in the record. So,when people search for 18 in an age field. User A record show up.

In other word,the very nice mod you gave me is to allow people use "range" search for the age of user. But now, people use "exactly" age (16) to search for the range of age user entered into the record (User A can enter 16 in "agefrom" field and 25 in "ageto" field in the record).

Does it make sense?? Smile

Quote Reply
Re: Ago search In reply to
hi again,
any idea of how to do the above???

THanks
Smile
Quote Reply
Re: Ago search In reply to
I'm sorry I had missed your response to the thread.

The mod I gave you is supposed to work exactly as you describe. You have two fields -- Age-gt and Age-lt. Someone searching enters 16 in the Age-gt field and 21 in the Age-lt field. Records of persons aged 18 will be returned from the search. That was the whole point of the mod. Smile


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






Quote Reply
Re: Ago search In reply to
Thanks again JPDeni Smile,
I understand that you have been helping so many people, of coz. sometimes you might have missed a few posts.. :P
Sorry,probably i am confusing you.
The mod you gave it to me is working prefect. But this time i would like to do is exactly different.
There are two age fields that user enter into the "record" (in add form). In other words, user can enter an expecting age range into the "record" (in add form) like the following :

Agefrom field : 16
Ageto field : 25

When people do a search by entering an age into a field like 18, the record of above example will show up.
Is it more clear?? Smile

Your any help would be greatly appreciated.
Quote Reply
Re: Ago search In reply to
Oh. I think I may have it. Let's see. Smile

When a person adds a record, he indicates the age range of people he would like to meet.

Then someone else comes to the site and does a search. This someone else is 18 years old and only wants to find people who are interested in meeting someone his age. Right?

The previous search allows the person to find someone he's interested in. What you're doing now will assure that the people he finds are also interested in him. Smile

Okay. Let's say the field on your search form is called Age_range.

In sub query, you would add (just after the stuff for the other age thing)

Code:
if ($in{'Age_range'}) {
$in{'agefrom-gt'} = $in{'Age_range'} + 1;
$in{'ageto-lt'} = $in{'Age_range'} - 1;
}

Make sure that you don't have a field in your .cfg file called "Age_range."

(I think this is correct. I get confused sometimes. Smile )


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






Quote Reply
Re: Ago search In reply to
yeah...that is what i want

Smile

THanks JPDeni,i will tell you later if it works

Quote Reply
Re: Ago search In reply to
i just tried it but it didnt work.

there are two fields called "agefrom" and "ageto" set in the .cfg.
The user enter 18 in "agefrom" and 25 in "ageto". After the user have added a record, I tried to enter 20 in the "Age_range" field in the search page to search for it. But it didnnt work.

By the way, there was one stranght thing.When i enter 0 in the "Age_range" field, the above record shown up.

Any thoughts??

Thanks :P
Quote Reply
Re: Ago search In reply to
I would recommend checking the case settings of your variables and field names. Make sure they match between lower/upper cases.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Ago search In reply to
Thanks a lot JPDeni,
It is kinda confusing. I tried some combination. The following is working :
Code:
if ($in{'Age_range'}) {
$in{'agefrom-lt'} = $in{'Age_range'} + 1;
$in{'ageto-gt'} = $in{'Age_range'} - 1;
}

THanks a lot Smile

One more littie question,i would like the date field for the "month" to be showed up as number like 12 instead of December in the view record page. I tried to change all the "month" to be the number in .cgi but no sccuess. How to do that??

Thanks again
Quote Reply
Re: Ago search In reply to
If your field names are correct, try switching the -gt and -lt tags. I told you this was confusing. Smile

Code:
if ($in{'Age_range'}) {
$in{'agefrom-lt'} = $in{'Age_range'} - 1;
$in{'ageto-gt'} = $in{'Age_range'} + 1;
}

Some combination should work.


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






Quote Reply
Re: Ago search In reply to
It would have been much easier if you would have done this before you had any records in your database. That way, the dates would already be in the correct format.

Just to be certain, you are using the "date translator" mod, right? If so, change sub get_computed_date to

Code:
sub get_computed_date {
# --------------------------------------------------------
# Returns the date in the format "dd-mm-yyyy".
# If you have changed your date format in sub get_date, you should also change it here.

my ($time) = $_[0];

$year = substr($time,0,4);
$mon = substr($time,4,2);
$day = substr($time,6,2);

unless ($day && $mon && $year) {
return undef;
}

return "$day-$mon-$year";
}

At the beginning of sub html_record_form, after

Code:
my (%rec) = @_;

add

Code:
$rec{'Date'}= &get_computed_date(&date_to_unix($rec{'Date'}));

Change Date above to match the name of your birthdate field.

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