Gossamer Forum
Home : Products : DBMan : Installation :

Range searches

Quote Reply
Range searches
Hi JP,
I need help with my problem,
I have a drop down list, which contains all the fields the user searches on and another option which indicates whether the search is greater or lesser than etc my search option looks like this
<SELECT NAME="rs">
<OPTION>---
~; for(my $i=1; $i<= $#db_cols; $i++){print qq~<OPTION VALUE="$db_cols[$i]">$db_cols[$i]</OPTION>\n~ if ($db_form_len{$db_cols[$i]} >= 0); } print qq~
</SELECT>
<SELECT NAME="co">
<OPTION VALUE=">=">Greater Than
<OPTION VALUE="<=">Less Than
</SELECT>
<INPUT TYPE="TEXT" NAME="rs-gt" SIZE=15 MAXLENGTH=255><br>
<SELECT NAME="pc">
<OPTION VALUE="&">AND
<OPTION VALUE="|">OR
</SELECT>
<SELECT NAME="ct">
<OPTION VALUE=">=">Greater Than
<OPTION VALUE="<=">Less Than
</SELECT>
<INPUT TYPE="TEXT" NAME="inputto" SIZE=1MAXLENGTH=255><br>
I can make the first part working by using

$in{$in{'rs'}}= $in{'inputo'}
if($in{'co'} eq ">="){
$in{$in{'rs'}=">".$in{'inputo'};}
if($in{'co'} eq "<="){
$in{$in{'rs'}="<".$in{'inputo'};}

I can get the fisrt part working.
but how do I make the second part working how do I set it such that it recognises that I am searching for a range and make the serach accordingly.Any Clues will be greatly greatly appreciated
I dont know if I am clear at all.
Your help wil be greatly appreciated.

------------------
smithan2
Quote Reply
Re: Range searches In reply to
Jp,
I have created a drop down list containing all the fields a user can search for ex:
age...
i have another drop down which has the option values (greater and Lesser) and an input box where the user enters a value
so it looks like this.
age > 7

Then I have another drop down (AND and Or)
yet another drop down (Greater and Lesser)
and an input box

so my screen after selecting looks like

Age > 7 AND < 9

Now I set the input to
after
local(%sortby)
$in{$in{'rs'}= $in{'inputo'};
inputo is the first input box which contains
the first selction
, I can get the first part working, that is my
search displays all the values for Age >7.
But now matter how hard I try I cannot get the second part working.Can you give me any clues or any other way where I can get my task accomplished.

Thanks in advance
Quote Reply
Re: Range searches In reply to
I'd need you to explain what you are doing with each part of it. I don't understand.


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





Quote Reply
Re: Range searches In reply to
How are you doing the "&" search?


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





Quote Reply
Re: Range searches In reply to
I am trying to combine both the greater and lesser than searches, when the user selects
'&'.

Code:
if($db_sort{$db_cols[$field]} eq "date") {
in{'ma'} ?
($key_match = ($key_match or (((&date_to_unix($values[$field])) > &date_to_unix($term))
&& ((&date_to_unix($values[$field])) < &date_to_unix($term1))))) :
(((&date_to_unix($values[$field]) > (&date_to_unix($term))) && (&date_to_unix($values[$field])
< (&date_to_unix($term1))))or next LINE);
}
elsif($db_sort{$db_cols[$field]} eq 'alpha') {
$in{'ma'} ?
($key_match = ($key_match or (($values[$field] > $term)
&& ($values[$field] < $term1)))) :
(((lc($values[$field]) gt lc($term)) &&
(lc($values[$field]) lt lc($term1)))or next LINE);
}
else {
$in{'ma'} ?
($key_match = ($key_match or (($values[$field] > $term) &&
($values[$field] < $term1)))) :
((($values[$field] > $term) && ($values[$field] < $term1))or next LINE);
}
},

How can I make the program recognise that it has to do both > and < searches.
I am building up a string like

>5<7(depending upon the user selections)
How can I assign 5 to collumn-gt and 7 to collumn-lt,
b'cos when building the search fields ,
$in{$column'}=^/>/
it stops as soon as it sees ">"
how can I make it to go further in the same
and see 5<7 and
filter for "<" and make collumn-lt =7.



[This message has been edited by JPDeni (edited June 18, 1999).]
Quote Reply
Re: Range searches In reply to
I edited your last post a little to see if I put in some formatting so I could read it. It did help somewhat.

The variable name which holds "Age > 7 AND < 9" is called "inputo"? (I'm just trying to get things straight.) And all the inputs would be in that form -- fieldname--space--greater-than--space--number--ANDorOR--less-than--space--number

If that is right, you could just split the variable into an array.

Code:
@variables = split(" ",$in{'inputo'});
$in{"$variables[0]-gt"} = $variables[2];
$in{"$variables[0]-lt"} = $variables[5];
if ($variables[3] eq "OR") {
$in{'ma'} = 1;
}


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