Help deal with shielding. Trying to make a 'dynamic query from the database'. Those. we have 2 tables, users and location. If the user specified a city when searching, we take this into account in the request; if not entered, we do not take into account and make the request without a filter by city. But I just can not figure it out with quotes. Then they interfere with each other, then they do not worry .. How to be?
if(isset($_POST['plusLocation'])){ //Π΅ΡΠ»ΠΈ ΡΠ·Π΅Ρ ΡΠΊΠ°Π·Π°Π» Π³ΠΎΡΠΎΠ΄ $thisCity=strip_tags($_POST['plusLocation']); $loc='AND l.city=$thisCity'; //Π² Π΄ΠΈΠ½Π°ΠΌΠΈΡΠ΅ΡΠΊΠΎΠΉ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ ΡΠΏΡΠ°ΡΠΈΠ²Π°Π΅ΠΌ Π³ΠΎΡΠΎΠ΄ }else{ $loc=''; //ΠΈΠ½Π°ΡΠ΅ Π΄Π΅Π»Π°Π΅ΠΌ Π·Π°ΠΏΡΠΎΡ Π±Π΅Π· Π³ΠΎΡΠΎΠ΄Π° } $query="SELECT * FROM table1 t INNER JOIN location l ON l.id=t.id WHERE t.age BETWEEN 20 AND 30 $loc"; //ΠΈ ΠΏΠΎΠ΄ΡΡΠ°Π²Π»ΡΠ΅ΠΌ Π² ΠΊΠΎΠ½Π΅Ρ ΠΈΠ»ΠΈ Π³ΠΎΡΠΎΠ΄ ΠΈΠ»ΠΈ Π½ΠΈΡΠ΅Π³ΠΎ