I run a pretty complex mysql query in php, which is working just fine, except that I don't know how to tackle the following problem:
My search page has, among others, the form field "TG". In php, the results page has the following code to match the setting of the search parameter:
$vartg_Recordset1 = "%";
if (isset($TG)) {
$vartg_Recordset1 = (get_magic_quotes_gpc()) ? $TG : addslashes($TG);
}
Of course, my php code also includes the database information, the table queried and the WHERE statement "LIKE '%s'
So far, so good. This works.
Now my question:
My database actually holds two tables with the same structure, but different field content (call it Option 1 and Option 2). E.g. table 1 may indicate "Hunting" and table 2 "Mountain Climbing" as available activities. The search form offers to choose just one preferred activity, but the query should check on both tables AND output the database results in case ANY of the two tables matches the search criteria "TG".
How do I do this?? I can't just add a second set of code like the one above and call it $vartg2, because then there will be no returns from the database, since only the field in one of the two tables will match. There must be some way of accomplishing it with an additional "if" line, but I have no clue how to phrase it.
Any help appreciated. Thanks!