Gossamer Forum
Home : Products : DBMan : Discussions :

search in one category only

Quote Reply
search in one category only
Hi,

I'm not sure whether this should go in customization or in this forum...

I've got the database set up with a category included. What I'd like is that people can search for a keyword, but if they pick a category, it only produces results that are in that category.

I've searched the board for a few hours, found hints, but they are meant for links2 mainly, and the solution is just not the same (I think) as a lot of stuff refered to isn't found in dbman, and a 'mod' that is mentioned a lot does not exist anymore.

Can anyone point me in the right direction?

Thanks!

Lex

nospam_Lex@peng.nl
Quote Reply
Re: search in one category only In reply to
Lex:

One way to accomplish this would be to setup a custom search form.

Then the users can choose a keyword and also choose to sort by a category.

Visit the FAQ noted below under the section "Searching" for examples.

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: search in one category only In reply to
I was already at your faq, looking under 'searching', and found some mod made by jpdeni that I thought might give me a clue, but I haven't been able to get what I need...

I saw the sorting by category mod as well, which is nice, but actually I only want results from one category. Should I go and try to modify the mod to my needs, or is that going a long way when a lot shorter way is available...

I've got a custom search form, but my problem is, that as soon as somebody types in a keyword, even if combined with a category, it searches (and produces results from) all records...

I don't know what to change exactly, was looking for the 'states' mod, but still can't figure it out...

And surely it can't be that difficult...

But thanks for replying, and I'll check your faq again.

Lex Wink

nospam_Lex@peng.nl
Quote Reply
Re: search in one category only In reply to
I still haven't been able to work it out, and I'm sure somebody must have done it before me...

Can anybody help? Frown

Thanks!

Lex

nospam_Lex@peng.nl
Quote Reply
Re: search in one category only In reply to
Using the following example:

<CENTER><$font><B>Search</B></font><P>
<FORM ACTION="$db_script_url" METHOD="GET">
<INPUT TYPE=hidden name="db" value="auto"> ## change to name of your database
<INPUT TYPE=hidden name="uid" value="$db_uid">
<INPUT TYPE=hidden name="so" value="descend">
<INPUT TYPE=hidden name="view_records" value=1>

<TABLE border=0 cellpadding=2 cellspacing=0 width=300>
<TR><TD><$font>Category:</font></TD><TD> |; print &build_select_field("Category",$rec{'Category'}); print qq|</TD></TR>
<TR><TD><$font>Choice1:</font></TD><TD><INPUT TYPE="TEXT" NAME="Choice1" SIZE="20" VALUE="$rec{'Choice1'}"></TD></TR>
<TR><TD><$font>Choice2:</font></TD><TD><INPUT TYPE="TEXT" NAME="Choice2" SIZE="20" VALUE="$rec{'Choice2'}"></TD></TR>
<TR><TD><$font>Choice3:</font></TD><TD><INPUT TYPE="TEXT" NAME="Choice3" SIZE="20" VALUE="$rec{'Choice3'}"></TD></TR>
<TR><TD><$font>Choice4:</font></TD><TD><INPUT TYPE="TEXT" NAME="Choice4" SIZE="20" VALUE="$rec{'Choice4'}"></TD></TR>
<TR align=center><td colspan=2><INPUT TYPE="SUBMIT" NAME="view_records" VALUE="Search"> <INPUT TYPE="RESET" VALUE="Reset"></TD></TR>
</TABLE></FORM></CENTER>

If someone chooses a category and then types a search term within one of the other field choices, and choose a category it should only list those records that are within the category chosen.

This is not a keyword search, as your users would be searching within specific fields to narrow down their search.

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: search in one category only In reply to
Thanks for answering!

But you said it already: not a keyword search...

And that's what I'd like. So they can search for 'whatever', in all fields, but if they've selected a category, then only produce results from that category.

...

Is it harder than it seems?

Thanks,

Lex

nospam_Lex@peng.nl
Quote Reply
Re: search in one category only In reply to
Okay try this:

<center><form action="cgi-bin/dbman/db.cgi" method="GET">
<input type=hidden name="uid" value="default">
<input type=hidden name="db" value="databasename">
<input type=hidden name="view_records" value="1">
<B>Keyword Search:<BR><input type="text" name="keywords" size="20">

<font size="2">Search within:

<INPUT TYPE="radio" NAME=Category VALUE="Category1">Category1<BR>
<INPUT TYPE="radio" NAME=Category VALUE="Category2">Category2</font></B><P>
<INPUT TYPE="SUBMIT" NAME="view_records" VALUE="Search"></FORM></center>

Making the necessary changes to the path of your db.cgi, name of database, and the categoy names.

I think this should do what you want. Sorry for the delay in getting back to you.

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: search in one category only In reply to
Sorry for the delay??? Shocked

Look, I haven't tried this yet, so I don't know if it works or not, but I am very, VERY happy this messageboard exist, and that you (like so many others) were willing to answer!

So no more sorry's, and I'll let you know if it works.

Thanks a lot!

Lex

nospam_Lex@peng.nl
Quote Reply
Re: search in one category only In reply to
Well,

this comes pretty close to what I've got right now. The problem with this is, as soon as I use the keyword field, no matter what fields you put on the search form more, it will give back all results from all records containing that keyword. It's hard to make it do this:

Have a look at all records containing the word 'wordX' in any field, then only show results if the same record has in the field category 'categoryY'.

It simply shows everything...

I've read about a mod used for the states of the US, that one should do the trick, (look for a keyword but only in 'Florida') but I can't find that one anymore... Some mods disappear...

Thanks for trying! Hope somebody has the clue I'm looking for.

Lex

nospam_Lex@peng.nl
Quote Reply
Re: search in one category only In reply to
I'm not sure it's possible to do what you want.

In the FAQ Search Tidbits there is a statement which says:

In order to search for text in more than one field, you have to set the "match any" flag. But it's not possible to "match any" just on certain fields. It's either "match any" or "match all."

I've setup many database, but I use custom search forms and had no problem doing searches without using the keywords.

If there was a mod to do what you wanted it would most likely be within the FAQ. I think if you read the various threads referenced there you will gain an understanding of using a keyword searches. It's amazing how much you can learn by the responses provided by JPDeni. And so much information is hidden within unrelated topics.


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: search in one category only In reply to
You're right, and I might as well try searching some fields in stead of using keywords...

Searching unrelated threads is indeed useful, but I'm afraid a bit too time-consuming...

Thanks a lot anyway,

Lex Wink

nospam_Lex@peng.nl