Thank you very much Matto, to don't let me alone in this hudge world of lines code...
I have try your second message and the outpout seems correct, but:
When I try to include it in my resaerch page I get the following code:
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 'select catgen.im_format from catgen where im_catgen like '%%')'
I have read on the PHP/Mysql O'Reilly book that Mysql doesn't like this kind of expression like:
select * from xy
where abc in(select abc from efg where klm="%search%"
I am loosing my mind.
To be sure to not make a mistake, here is a correct draw of my tables:
Phototek:
+----------------+--------------+------------------+-------------+------------+
| Image ID | im_name | comments | formatID | catgenID |
+----------------+--------------+------------------+-------------+------------+
| 1 | 006.jpg | blonde | 2 | 1 |
+----------------+--------------+------------------+-------------+------------+
format
+------------+---------------+
| formatID | im_format |
+------------+---------------+
| 1 | color |
| 2 | B & W |
+------------+---------------+
catgen
+-------------+---------------------+
| catgenID | im_catgen |
+-------------+---------------------+
| 1 | backgrounds |
| 2 | business |
| 3 | people
etc.... |
+------------+----------------------+
So if I understand your code it wil be now (to test i have done it only on 2 tables:
$keywords = explode(' ', $searchstring);
$clause = "im_name like '%"
.implode("%' or im_name like '%", $keywords)
."%'";
$clause2 = "im_catgen like '%"
.implode("%' or im_catgen like '%", $keywords)
."%'";
$query_rsSearch = "select * from phototek where "
."$clause or "
."formatID in(select catgen.im_format from catgen where $clause2) or ";
."catgenID in(select im_catgen from catgen where $clause)";
// ."id_category3 in(select id from category3 where $clause)";
Am I right or am I wrong?
Sincerely yours,
Marc-André