Simple MySQL Search from MySQL beginner

Hi,

I'm trying to build a simple search for a database of jobs. Users can
search using three groups of critera:

1) Area (check boxes)

[ ] Buying and merchandising
[ ] Design
[ ] Executive
[ ] Human resources
[ ] Manufacturing
[ ] Retail operations
[ ] Sales and marketing
[ ] Technical
[ ] Visual merchandising

2) Location (dropdown)

All, UK specific, Africa, Asia, Europe, Middle East, Americas, Oceania


3) Keyword (single text box)

I'm currently using the following:

---

$location= $HTTP_GET_VARS['searchlocation'];
$keyword= '%'. $HTTP_GET_VARS['searchkeyword'] . '%';
$bm = $HTTP_GET_VARS['buying_and_merchandising'];
$design = $HTTP_GET_VARS['design'];
$executive = $HTTP_GET_VARS['executive'];
$hr = $HTTP_GET_VARS['human_resources'];
$manufacturing = $HTTP_GET_VARS['manufacturing'];
$ro = $HTTP_GET_VARS['retail_operations'];
$sm = $HTTP_GET_VARS['sales_and_marketing'];
$technical = $HTTP_GET_VARS['technical'];
$vm = $HTTP_GET_VARS['visual_merchandising'];

$query = "SELECT * FROM jobs WHERE location LIKE '$location' AND
description LIKE '$keyword' AND (`buying and merchandising` LIKE '$bm'
OR design LIKE '$design' OR executive LIKE '$executive' OR `human
resources` LIKE '$hr' OR manufacturing LIKE '$manufacturing' OR `retail
operations` LIKE '$ro' OR `sales and marketing` LIKE '$sm' OR technical
LIKE '$technical' OR `visual merchandising` LIKE '$vm' ) ";

$result = [at] mysql_query ($query);

----

If you pick a location or enter a keyword it works OK, but checking a
check box (the job areas) to narrow the results down doesn't work...

Any ideas on a straightforward MySQL query to solve this would be much
appreciated (I'm quite new to this!).

Thanks,

OP.
odysseyphotography [ Di, 27 Juni 2006 12:51 ] [ ID #1371936 ]
Datenbanken » mailing.database.mysql » Simple MySQL Search from MySQL beginner

Vorheriges Thema: Configure mysql to compensate for bad structure/queries
Nächstes Thema: Backing Up Stored Procs