Gossamer Forum
Home : Products : DBMan : Installation :

Minimum & Maximun

Quote Reply
Minimum & Maximun
Hi there:

I am tring make two fields to search age. If is possible to make two fields of MINIMUM and MAXIMUN to search my the age field I input?

Ex. If I input 20 years old in my AGE field

When a person look for 15 Years old in MINIMUN field to 35 years old in MAXIMUN field, it will show my infomation (because I inputed 20 years old)

I also want have a Unlimited option in my MAXIMUN field.

Good day!
Quote Reply
Re: Minimum & Maximun In reply to
Hi Aston,

I am sure there are a million ways of doing this but the first one that comes to mind is to put an if condition in your query sub

something like..
if (($in{'Max'} > $Max) or ($in{'Min'} < $Min)) { return "Wrong Age Range"; }

Note that I invented the variables $Max, $Min, $in{'Max'}, $in{'Min'}. You will have to create them... $Max and $Min could be in your .cfg file and $in{'Max'} and $in{'Min'} should be the variables passed through the submit form...

Cheers
-JO

[This message has been edited by Jaime Ortega (edited March 22, 1999).]
Quote Reply
Re: Minimum & Maximun In reply to
Hi Jaime Ortega:

I am just a begginer with perl and DBMan, if passible tell me more of detail step to do this?

(I know how to create $Max and $Min in my .cfg file, but I don't what is "$in{'Min'} should be the variables passed through the submit form..." means.)

Such as, which file(s) that I have to edit it and which part of the file that I have modify it?

Quote Reply
Re: Minimum & Maximun In reply to
Hi Aston

in your html.pl you need to add something similar to this
Code:
<TR><TD ALIGN="Right" VALIGN="Center" WIDTH="27%"><$font><b>Minimum Age:</b></FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Min" VALUE="$rec{'Min'}" SIZE="19" MAXLENGTH="20"></TD></TR>

<TR><TD ALIGN="Right" VALIGN="Center" WIDTH="27%"><$font><b>Maximum Age:</b></FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Max" VALUE="$rec{'Max'}" SIZE="19" MAXLENGTH="20"></TD></TR>

in your html_record_form sub.

Whenever you enter values inside the two fields and click on the add record button, the values will be passed to your db.pl file.
The values will be stored in $in{'Max'} and $in{'Min'}. If you now go to the db.pl file, to the query sub, you can put the other piece of the code
Code:
if (($in{'Max'} > $Max) or ($in{'Min'} < $Min)) { return "Wrong Age Range"; }
right after
Code:
# If we don't have anything to search on, let's complain.
if (!@search_fields and !@search_gt_fields and !@search_lt_fields) {
return "no search terms specified";
}


Min and Max need to be defined in your %db_def variable in the .cfg file too.

$in{'Max'} and $in{'Min'} should be the variables passed through the submit form... just means that the values you entered in Min and Max (first part of the code) will be passed to the db.pl file when you click on the add record button (that is the submit button).

Let us know what happens...

Cheers
-JO

PS: The now almost legendary, I have not tested this, disclaimer applies Smile


[This message has been edited by Jaime Ortega (edited March 30, 1999).]