Answer the question
In order to leave comments, you need to log in
How to make a selection from the database for a certain category?
The essence of the question is this: there is a very old site on pehe, two tables in MySQL
table1 (goods / services)
-----------------------
| id | name | cat_id |
-----------------------
and table2 (categories themselves and category attributes)
------------------ ---------
| id | name | desc | etc. |
---------------------------
The `cat_id` field contains entries such as:
$multicat = ($cat['id'] !=1 )?"(`category` REGEXP '".$cat['id']."(?=,|$)' or `category`='".$cat['id']."')":"(`category` REGEXP '".$cat['id']."(?=,)' or `category`='".$cat['id']."')";
$select = 'select `name` from `table1` where '.$multicat.' order by `id` asc');
Answer the question
In order to leave comments, you need to log in
urgently need a solutionChange the database structure. There simply cannot be another solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question