Answer the question
In order to leave comments, you need to log in
How to concatenate SQL query strings in PHP when certain checkboxes are selected?
Basically, I'm creating an interface for uploading sales data and comparisons between cities.
I made separate checkboxes for each of the cities. I need to make sure that when specific checkboxes are selected, SQL strings with the name of the city are selected.
Give advice how to write it in PHP and what to use?
The query below indicated
select
sum (case when t.subs_subs_id = 244 ) Rostov,
sum(case when t.subs_subs_id = 246 ) Novosibirsk,
sum(case when t.subs_subs_id = 243 ) Irkutsk,
sum(case when t.subs_subs_id = 222 ) Peter,
sum(case when t.subs_subs_id = 249 ) Novocherkassk,
sum(case when t.subs_subs_id = 662 ) Yekaterinburg ,
sum(case when t.subs_subs_id = 363 ) Krasnoyarsk,
sum(case when t.subs_subs_id = 182 ) Kazan ,
sum(case when t.subs_subs_id = 232 ) Ufa,
sum(case when t.subs_subs_id = 302 ) Moscow,
trunc( t.start_date, 'dd')
from shops t,
sell c
where c.subs_id = t.subs_subs_id
and t.start_date >= '08/01/2020'
group by trunc(t.start_date, 'dd')
order by trunc(t .start_date, 'dd') desc
Answer the question
In order to leave comments, you need to log in
Lines with cities in an associative array, checkbox name = array key, and in accordance with what comes from the form, form a query string.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question