Gossamer Forum
Home : Products : DBMan : Customization :

Combine range search

Quote Reply
Combine range search
Hi all,

I would like to know is it possible to combine range search in one part, not two?
Like "Disk Space Requirement","Data Transfer" search in http://www.webhosters.com/database/search/power/index.html

Appreciated any help!

Kavis
Quote Reply
Re: Combine range search In reply to
Do you want it exactly like the page you referenced? I'll need to know the format for the options you want.

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





Quote Reply
Re: Combine range search In reply to
Thanks for your reply!

Yes, i want to have a search formatlike "Disk Space Requirement","Data Transfer" in that site.

I'm trying to do that but first i don't know how to combine the range search to single one, second, even if I use two part range search, i can't do a search for unlimited data transfer though search for other countable data transfer works smoothly.

Here's my site:
http://webhoster.hypermart.net/dbman/db.cgi?db=default&uid=admin.93327210457575&view_search=1

Here the code for data transfer search:

========================================
Datatransfer => [13, 'numer', 12, 12, 1, '', ''],
==========================================




'Datatransfer-lt' => [
['99999999','no maximum'],
['1001','1GB'],
['2001','2GB'],
['3001','3GB'],
['10001','10GB'],
['unlimited','unlimited']],


'Datatransfer-gt' => [

['---','no minimum'],
['999','1GB'],
['1999','2GB'],
['2999','3GB'],
['99999','10GB'],
['unlimited','unlimited']],

========================================

Data Transfer:
~; print &build_fancy_select_field("Datatransfer-gt",$rec{'Datatransfer'});
print &build_fancy_select_field("Datatransfer-lt",$rec{'Datatransfer'});
print qq~
============================================

Thanks

Kavis


[This message has been edited by Kavis (edited July 29, 1999).]
Quote Reply
Re: Combine range search In reply to
I think you're going to have to come up with some number for "unlimited." It might be that, once we get the code worked out for your one select field, you could use -1 or 0 for unlimited. I'm not sure until I know exactly the format you want to use.


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





Quote Reply
Re: Combine range search In reply to
Sorry for my ignorance, could you specify what format you're talking about.

What a shame for me.
Quote Reply
Re: Combine range search In reply to
Sorry. I should have been clearer.

I'm not sure how I can be clearer. Smile

I'll tell you what. Create a select field that looks like the one you want to use. I'll get a better idea then.

Is this just for searching, or will it also be for entering data?


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





Quote Reply
Re: Combine range search In reply to
It's not your fault!! ^.^

I use it to search the database. I want people to add that data by write down how much data transfer will they provide e.g 2000MB, then when other select a choice of "1GB - 2GB" of in the search form, that company will show up for they match it.

Do you know what i mean. Sorry for many times, i'm new to database and perl.

Quote Reply
Re: Combine range search In reply to
Please post the exact select field you want to use. You can define it just about any way you want to. If there are problems with it, I can tell you what needs to be changed. But I have to know what the select field will look like in order to give you the code to translate the input into something DBMan can use to do the search.


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





Quote Reply
Re: Combine range search In reply to
Here is the select and add field i want: http://webhoster.hypermart.net/select.htm

Is it what you want to know?

Thanks!!

Kavis
Quote Reply
Re: Combine range search In reply to
Well, I was hoping that you would have the actual values included so I would know what I'm going to be working with. But I think I can figure it out.

For "unlimited" values, set the value to -1.

Your data transfer needs to be:

Code:
<select name=datatransfer>
<option value="---" selected>
No preference
<option value="1000">
Less than 1GB
<option value="1000 - 5000">
1GB - 5GB
<option value="5000 - 10000">
5GB - 10GB
<option value="10000+">
More than 10GB
<option value="-1">
unlimited
</select>

Your monthly storage needs to be:

Code:
<select name=monthlystorage>
<option value="---" selected>
No preference
<option value="5" selected>
Less than 5MB
<option value="5 - 10">
5MB - 10MB
<option value="10 - 20">
10MB - 20MB
<option value="20 - 30">
20MB - 30MB
<option value="30 - 40">
30MB - 40MB
<option value="40 - 50">
40MB - 50MB
<option value="50">
Less than 50MB
<option value="50 - 150">
50MB - 150MB
<option value="150+">
More than 150MB
</select>

(No "unlimited" option on storage?)

In db.cgi, sub query, just after

local (%sortby);

add

Code:
if ($in{'datatransfer'} gt -1) {
$in{'datatransfer'} =~ s/ //g;
@trans = split "-",$in{'datatransfer'};
$in{'datatransfer'} = '';
if ($trans[0] =~ /\+/) {
$trans[0] =~ s/\+//;
$in{'datatransfer-gt'} = $trans[0];
}
elsif (!$trans[1]) {
$in{'datatransfer-lt'} = $trans[0];
}
else {
$in{'datatransfer-gt'} = $trans[0];
$in{'datatransfer-lt'} = $trans[1];
}
}
if ($in{'monthlystorage'} gt -1) {
$in{'monthlystorage'} =~ s/ //g;
@stor = split "-",$in{'monthlystorage'};
$in{'monthlystorage'} = '';
if ($stor[0] =~ /\+/) {
$stor[0] =~ s/\+//;
$in{'monthlystorage-gt'} = $stor[0];
}
elsif (!$stor[1]) {
$in{'monthlystorage-lt'} = $stor[0];
}
else {
$in{'monthlystorage-gt'} = $stor[0];
$in{'monthlystorage-lt'} = $stor[1];
}
}

You do understand that you will need to have a search form that is different from your add/modify form, right?


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





Quote Reply
Re: Combine range search In reply to
I'm trying to run dbman after insert the upper code in sub html_record_form and sub html_search_options in html.pl. And the lower code in db.cgi. Also try to copy the format of other code in sub html_record of html.pl in sub html_record. I haven't made change because i'm not sure how to do. I could only add record, search is failed.

Is it a correct way to add the upper code in sub html_record_form and sub html_search_options without editing what you've shown me. I'm wondering if there will be somewhere i should add $rec, ~;, qq~. This type of question seems very stupid to you. I totally don't know perl, if you think there has technical problem to teach me doing that, just forget it. I could do with range search.

Thanks a lot for your extraordinary patience.

Kavis

[This message has been edited by Kavis (edited July 30, 1999).]
Quote Reply
Re: Combine range search In reply to
Thanks a lot!!

Here's the html_pl.txt:

http://webhoster.hypermart.net/html_pl.txt

Thanks again!

Kavis
Quote Reply
Re: Combine range search In reply to
You don't want to put the select fields into html_record_form. You'll have text input fields for the actual values to be entered and modified.

The way you have added the code to html_search_options looks like it will work.

Did you add the code to sub query in db.cgi? There's no way your range searches will work unless you do.


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





Quote Reply
Re: Combine range search In reply to
Thanks very much! It works! But..

When i add some records like 10, 1000, 2000. Search failed. Is it possible to make able to search these number too? Just like in " sub build_fancy_select_field"

===========================================
'Meg-lt' => [

['99999999','no maximum'],
['6','5MB'],
['11','10MB'],
['21','20MB'],
['31','30MB'],
['41','40MB'],
['51','50MB'],
['101','100MB'],
['201','200MB'],
['301','300MB']],

'Meg-gt' => [

['---','no minimum'],
['4','5MB'],
['9','10MB'],
['19','20MB'],
['29','30MB'],
['39','40MB'],
['49','50MB'],
['99','100MB'],
['199','200MB']],
============================================
to have -,+1?

Also, i've created a text input for actual value of datatransfer and monthlystorage, but what should i fill in if the value is unlimited?

Thnaks!!!

Kavis
Quote Reply
Re: Combine range search In reply to
Can you let me take a look at your html.pl file? Copy it to a web-accessible directory -- one where you would place html files -- and rename the file to html_pl.txt. (If I've already told you this and you have it available, sorry. I have a hard time keeping track. Smile ) Then come back and let me know where the file is and I'll take a look at it.


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





Quote Reply
Re: Combine range search In reply to
 
Quote:
When i add some records like 10, 1000, 2000. Search failed. Is it possible to make able to search these number too?

I don't understand. Are you including a text field in addition to your range search?

The range search select field I gave you is to be used instead of the "-gt" and "-lt" select fields. It will work.

Quote:
Also, i've created a text input for actual value of datatransfer and monthlystorage, but what should i fill in if the value is unlimited?

-1



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





Quote Reply
Re: Combine range search In reply to
In "sub html_record_form", I replaced the select field with:
===========================================
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>datatransfer:</FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="datatransfer" VALUE="$rec{'datatransfer'}" SIZE="10" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>monthlystorage:</FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="monthlystorage" VALUE="$rec{'monthlystorage'}" SIZE="10 MAXLENGTH="255"></TD></TR>
===========================================
And the select field you gave me I've put in "sub html_search_options". You could see my html.pl at http://webhoster.hypermart.net/html_pl.txt

Problem is (e.g):
I tried to add record and input 1000 into the datatransfer field. After added the record, i went to search, and chose 1GB - 2GB in datatransfer select field, search failed. On the contrary, if i input 1500 into the datatransfer field when i add record, search succeeded when i chose "1GB - 2GB" in select field. All i want is make the select field able to search any value. Just like I used range search before, e.g, though the select field show it is "10MB" but the actual value of it is "9" in -gt and "11" in -It.

Maybe you could do a search here http://webhoster.hypermart.net/dbman/db.cgi?db=default&uid=admin.93348781843943&view_search=1

My database only have two records, one's datatransfer is "5000", another is "2500". You could choose "1GB - 5GB", only the former one will be shown as matched. Even if you choose "5GB - 10GB", the former one won't shown up too. In another word, the former is out of the range. (monthlystorage also has the same problem)

My second question is: In the datatransfer select field, has a "unlimited" choice, if I'm a webhost and provide unlimited datatransfer, what should i input in the datatransfer input place, input "unlimited" or "-1" or any others?

I know my question is lengthy and dull, hope you don't mind.

Kavis

Quote Reply
Re: Combine range search In reply to
I see what you mean now. Okay.

Code:
<select name=datatransfer>
<option value="---" selected>
No preference
<option value="1001">
Less than 1GB
<option value="999 - 5001">
1GB - 5GB
<option value="4999 - 10001">
5GB - 10GB
<option value="10000+">
More than 10GB
<option value="-1">
unlimited
</select>
<select name=monthlystorage>
<option value="---" selected>
No preference
<option value="5" selected>
Less than 5MB
<option value="4 - 11">
5MB - 10MB
<option value="9 - 21">
10MB - 20MB
<option value="19 - 31">
20MB - 30MB
<option value="29 - 41">
30MB - 40MB
<option value="39 - 51">
40MB - 50MB
<option value="50">
Less than 50MB
<option value="49 - 151">
50MB - 150MB
<option value="150+">
More than 150MB
</select>

Quote:
My second question is: In the datatransfer select field, has a "unlimited" choice, if I'm a webhost and provide unlimited datatransfer, what should i input in the datatransfer input place, input "unlimited" or "-1" or any others?

I would put -1.

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





Quote Reply
Re: Combine range search In reply to
I don't know how to express my good feeling and appreciation to you. THNAKS!!! It works extreme perfectly and beautifully.

Thanks again for your patience!!