Q
Q
qu1kgg2020-12-30 16:52:15
PHP
qu1kgg, 2020-12-30 16:52:15

How to select from js array in mysql using php?

Good afternoon, I'm doing a product filter, tell me how to make a selection in the database, where the param column has data of this type ["value1","value2","value3"]?
imput example:

<li class="" style="width: 85%;"><input  name="param[]" type="checkbox" value="значение2" style="display:none" >значение2</li>
<li class="" style="width: 85%;"><input  name="param[]" type="checkbox" value="значение3" style="display:none" >значение3</li>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
FanatPHP, 2020-12-30
@FanatPHP

The param column must not have "this type" of data.
We need to redo this horror so that the param column becomes a param table

Y
Yuri Kulaxyz, 2020-12-30
@Kulaxyz

1) https://dev.mysql.com/doc/refman/8.0/en/json.html#...
2) A not entirely correct alternative solution is to form a string based on the form data and make several conditions. For example, you need to apply only the first filter, and display everything for the other two:
Etc.
Of course, not manually writing everything, but somehow generating a request in a cycle

V
Vladimir Maltsev, 2020-12-31
@mrhard

If HTML in one line
If HTML in different lines

SELECT * FROM `table` WHERE `field_html` LIKE '%value="значение1"%' OR  `field_html` LIKE '%value="значение2"%' OR  `field_html` LIKE '%value="значение3"%'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question