Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How do I add filters to the advanced search form?

Quote Reply
How do I add filters to the advanced search form?
How do I add filters to the advanced search form?

What I want is to allow users to limit their searches by specifying a state, country, category or zip code.

state, country and categories are all select fields that are on all listings. zip code is an optional open field.

The first three is what I'm most interested in although zip code would be nice too.

An even nicer feature would be to enable search of more than one option such as -

search for breeders of Bengal cats in NY or CT.

I've been looking everywhere but can't find this info. I don't see a plug-in that lets me do this and I can't figure out how to edit the search template to acheive this.

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] How do I add filters to the advanced search form? In reply to
search.cgi?query=blabla&State=NY

Its as simple as that. Create a drop down box, with the user value that is shown, and the value that is stored in the database, and then run the search as normal.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How do I add filters to the advanced search form? In reply to
Thanks!

I'm not clear about the blabla part though Unsure

This is what the code looks like now:

Code:
<form action="<%db_cgi_url%>/search.cgi" method="GET">
<table border="0" cellpadding="0" cellspacing="0">

<%if error%>
<tr><td colspan=2>

<%error_font%><b><%error%></b><br><br>
</td></tr>
<%endif%>
<tr><td>
<%body_font%>Search:</font></td><td><input type="TEXT" name="query" size="30" class="button">
<input type="Submit" value="Search" class="button"></td></tr>

<tr><td></td><td>
<input type="RADIO" name="bool" value="and" CHECKED><%body_font%>Results must contain all words</font>
</td></tr><tr><td></td><td>
<input type="RADIO" name="bool" value="or"><%body_font%>Results can contain any of the words</font>
</td></tr>
<tr><td></td><td>

<input type="RADIO" name="substring" value="1"><%body_font%>Find similar words </font>
</td></tr><tr><td></td><td>
<input type="RADIO" name="substring" value=0 CHECKED><%body_font%>Find exact words </font>
</td></tr>
<tr><td colspan="2"><br></td></tr>
<tr><td><%body_font%>Number of Results:</font></td><td><SELECT name="mh"><OPTION>10<OPTION SELECTED>25<OPTION>50<OPTION>100</SELECT></td></tr></table>

<br><br>
</form>


Now I want to add this field:

Code:


<select name=
"State">
<option>AL
<option>AZ
<option>CA
<option>CO
<option>CT
<option>AK


<option>N/A

</select>


With all the states. I have a State column in my links table. How do I connect the two? Where do I insert the search.cgi?query=blabla&State=NY part? what do I do with the "blabla"?

Shocked You make it sound so easy - but I'm a total newbiw - sorry Blush

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] How do I add filters to the advanced search form? In reply to
You just name the form field on the search page the same as your column and that's all you need to do.

When you submit the form the selected state will be passed along to the search script with the query.

Last edited by:

Paul: Sep 22, 2002, 6:18 AM
Quote Reply
Re: [Andy] How do I add filters to the advanced search form? In reply to
In Reply To:
search.cgi?query=blabla&State=NY

Its as simple as that. Create a drop down box, with the user value that is shown, and the value that is stored in the database, and then run the search as normal.


If I do the above (eg search.cgi?query=blabla&Title=phoenix) I get no match.

If I do search.cgi?query=&Title=phoenix I get:

Can't call method "fetchall_hashref" on an undefined value at /home/.sites/44/site22/web/cgi-bin/admin/Links/User/Search.pm line 147.

GT::SQL::error = Failed to execute query: 'SELECT * FROM sa_Links WHERE ( isValidated = ? AND Title LIKE ? )
ORDER BY PriorityTier DESC,
LIMIT 0, 3' Reason: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 3' at line 3

phoenix does exist in the column Title table Links

If I do search.cgi?query=phoenix I get a result.

Any ideas please? Thanks. Smile

Thanks,
--Jo