Gossamer Forum
Home : Products : DBMan SQL : Discussion :

How do I get exact Search Results

Quote Reply
How do I get exact Search Results
I have set up a simple search form which has two select fields and a submit button. One field is discipline and one field is region. When I search and select south east for example it also pulls any records for south west. The same goes for north east and north west.I have tried adding a hidden field as below

<input type=hidden name="REGION-opt" value="=">

any ideas much appreciated
Quote Reply
Re: [jamesamorris] How do I get exact Search Results In reply to
When you set up the database, define the region column like this (for example):

Column Name:
REGION

Column Type:
ENUM

Column Values:
N
E
S
W
NE
NW
SE
SW

Form Names:
same as in Column Values

Form Values:
North
East
South
West
North East
North West
South East
South West


Assuming you don't use the default template, you could put this in your custom search_form.html:

<select name="REGION">
<option value="N">North</option>
<option value="S">South</option>
...
...
</select>
<input type="hidden" name="REGION-opt" value="=">


Or via direct URL (example for North East):
yourdomain.com/path/to/db.cgi?do=search_results&REGION=NE&REGION-opt==

Let me know if this helps.
Smileliver
Quote Reply
Re: [olivers] How do I get exact Search Results In reply to
Thankx for the help but i now find myself in another mess.

I now have two fields for each record - ShortRegion and Long Region. I want to use a select box that is automatically generated on my search page and only shows the values that appear in the DBASE. I want the box to show Long Region but carry out the search on short region i am using the code below but it doesnt wanna work. Any ideas much appreciated. I am using MS Access and ODBC My SQl Drive to update the database from my local PC so the use of the Short and Long Region fields is not too complex.

sub {
my $tags = shift;
my $table = $DB->table('JOBS_MASTER');
my $sth = $table->select (['DISTINCT SHORTREGION']);
my $output = '<select name=SHORTREGION><OPTION>';
while (my $row = $sth->fetchrow_hashref) {
$output .= '<option value='.$row->{SHORTREGION}.'>'.$row->{LONGREGION}.'</option>';
}
$output .= '</select>';
return $output;
}

Cheers
Quote Reply
Re: [jamesamorris] How do I get exact Search Results In reply to
Hello again,

I don't think it's necessary to create two region fields to make it work as you want: just define one field that will save the short "region code" and use DBMan SQL's table editor to add the long regions (that will be displayed in the form). Just follow the instructions in my previous post. DBMan SQL will take care of the rest. I also think that a sub is not required.

Good luck,
Oliver
Quote Reply
Re: [jamesamorris] How do I get exact Search Results In reply to
Try the code below:

sub {
my $tags = shift;
my $table = $DB->table('JOBS_MASTER');
$table->select_options('GROUP BY SHORTREGION']);
my $sth = $table->select();
my $output = '<select name=SHORTREGION><OPTION>';
while (my $row = $sth->fetchrow_hashref) {
$output .= '<option value='.$row->{SHORTREGION}.'>'.$row->{LONGREGION}.'</option>';
}
$output .= '</select>';
return $output;
}


Hope that helps.

TheStone.

B.