Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, Can anyone help me modify this script so it can have 3 range fields instead of just one? There are 2 areas in the script that may need to be modified. Sorry I am such a newb, I am so lost, need help desperatly :(
# Determine if there is a field upon which a range search should be performed.$RANGEFIELDNAME = $query->param("RangeField");
# If the user specified a range field, then refine the search on the base
# of that field
if ($RANGEFIELDNAME) {
# Determine the minimum value of the search range
$RANGEMIN = $query->param("RangeMin");
# Determine the maximum value of the search range
$RANGEMAX = $query->param("RangeMax");# Refine the search
@results = &search_by_range($RANGEFIELDNAME, $RANGEMIN, $RANGEMAX);
}print $query->header;
&display_results($start_rec, $max_hits, @results);
exit 0;
--------------------
# search_by_range -- Refine a search by isolating the records for which a
# user-specified field lies within a certain range of
# values.
--------------------sub search_by_range {
my ($fieldname, $range_min, $range_max) = @_;
my @new_results;# Loop over all records found by search_by_pattern
for (my $i = 0; $i < @results; $i++) {
my @field_value = split(/\|/, $results[$i], $TOT_FIELDS);
if (($range_min <= $field_value[$field_pos{$fieldname}]) &&
($field_value[$field_pos{$fieldname}] <= $range_max)) {
push(@new_results, $results[$i]);
}
}return @new_results;
}

Yor're already searching between min and max so what else do you need; mean, mid, mod?
Or, did you mean,
$RANGEFIELDNAME1 = $query->param("RangeField1");
$RANGEFIELDNAME2 = $query->param("RangeField2");In either case, we need more info on your search form and what you're trying to accomplish.

Hi,
Yes I need to add 2 more form fields that are range searches. I have already tried doing what you suggested to no avail.
Example: 3 form fields
Size......range between 1 and 10(min/mqx)
Weight....range between 1 and 10(min/mqx)
Quality...range between 1 and 10(min/mqx)

Your code is conviluted and your discription makes it even more confussing. Your subroutine is directly using global variables which normally sould not be done. Pass the varibles to the subroutine.
Where is your data comming from i.e., flat file or database and can you show me the code you're using to bring the data into the script? What does the record data look like? Please give some example records. Is the record data for all 3 fields within the same source/record?

Hi, thanks for taking the time to offer your assistance.
I am using a script called edb(found it free on the net). It uses global vars because of the one range search. I believe this is why I can't add any others.
Here are links to sample files.(don't want to take up space posting the code here)
Sample Script:
http://www.neidiamonds.com/test/searchcgi.txt
Sample Data File:
http://www.neidiamonds.com/test/sampledata.txt
Sample config File:
http://www.neidiamonds.com/test/edbcfg.txt
Sample Html:
http://www.neidiamonds.com/test/search2.htmlAgain Thanks for your time.

![]() |
XP home web servers (free...
|
Simple automated newslett...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |