Computing.Net > Forums > Web Development > Need Help with CGI Range search

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need Help with CGI Range search

Reply to Message Icon

Name: Xoplex
Date: June 8, 2005 at 11:38:14 Pacific
OS: -
CPU/Ram: -
Comment:

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;

}



Sponsored Link
Ads by Google

Response Number 1
Name: FishMonger
Date: June 8, 2005 at 23:33:03 Pacific
Reply:

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.


0

Response Number 2
Name: Xoplex
Date: June 9, 2005 at 12:34:29 Pacific
Reply:

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)


0

Response Number 3
Name: FishMonger
Date: June 10, 2005 at 11:12:58 Pacific
Reply:

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?


0

Response Number 4
Name: Xoplex
Date: June 15, 2005 at 12:38:46 Pacific
Reply:

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.html

Again Thanks for your time.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


XP home web servers (free... Simple automated newslett...



Post Locked

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


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Need Help with CGI Range search

Help with CGI, pHp, VB! www.computing.net/answers/webdevel/help-with-cgi-php-vb/1186.html

Help with div layers and background www.computing.net/answers/webdevel/help-with-div-layers-and-background/2257.html

help with php code! www.computing.net/answers/webdevel/help-with-php-code/3049.html