|
Posted by Hank on 09/01/06 17:43
On 31 Aug 2006 11:27:59 -0700, kenoli wrote...
>
>I am designing a database with several "key word" columns. Users
>wanting to search the database will enter terms into html form fields
>from drop down menus populated from existing lookup tables or by adding
>their own terms which may, in some cases, be inserted into the lookup
>tables for subsequent users. Some of the form fields may be left
>empty.
>
>I want to create a query that will include all terms entered into a
>field in the form, search the "key word" columns for those terms and
>return the IDs of records that have those key words in their "key word"
>columns.
>
>I haven't started doing this, though I can see it will raise issues
>like vlidating data, what to do with empty form fields, and turning the
>form data into a proper SQL query. I can see using the SQL function
>IN() and a bunch of ORs.
>
>Does anyone know where I can find some procedural code (preferable) or
>an object class to help me do this?
>
>Thanks.
>
>--Kenoli
>
>Kenoli Oleari
>Neighborhood Assemblies Network
>kenoli@sfnan.org
>510-601-8217
>http://www.sfnan.org
>http://www.horizonsofchange.com
>
Since you would know your form fields ahead of time ($_GET or $_POST vars) you
can do a couple steps to validate each of the fields and append them to your
query with an "and" or "or" lookup.
If you anticipate changes down the road, it may be worth creating a couple of
functions to validate (check for nulls or junk text) and to build your query for
SQL.
Hank
--
Newsguy's Help-A-Community Program
Help a community by participating in ours!
http://newsguy.com/charity.asp
Navigation:
[Reply to this message]
|