Dynamically create a mysql select query


I need a mysql query dynamically generated from post data.

This is the table structure of the table which needs to be queried:

c_id tag_id

1 1

1 2

2 1

The post data prints like this:

[tags] => Array


[param] => all

[value] => Array


[0] => 1

[0] => 2



The value array above is the array of tag_id and is chosen from a multiple select list so any number of tag_id's can be in that array.

The query i would need to create based on the post data above would need to select any contact (c_id) which is assigned to both tag 1 and tag 2.

In the case of the table above c_id 1 would be selected but not c_id 2.

The basic query used to select this is

SELECT c1.c_id FROM tag_table c1 JOIN tag_table c2 on c1.c_id = c2.c_id WHERE c1.tag_id = 1 AND c2.tag_id = 2

However I need this to be generated dynamically.



Beceriler: MySQL, PHP

Daha fazlasını gör: create query dynamically mysql, n query, data structure in array, data structure array, create table php, array in data structure, array data structure, select, query table, mysql query, data query, create 1-2, c1, php mysql join table, mysql join table, mysql table join, mysql structure, php table array, php post array, php post value, mysql create table data, php mysql query multiple, dynamically generated, mysql create table, php value post

İşveren Hakkında:
( 23 değerlendirme ) Sheffield, United Kingdom

Proje NO: #707338



VALUEONWEB is a customer-specific service oriented company has got a Professional and creative team. We are the Professional Web Development Company having rich experience in Web design and development. We have exp Daha Fazla

%selectedBids___i_period_sub_7% gün içinde 30%project_currencyDetails_sign_sub_9% %project_currencyDetails_code_sub_10%
(213 Değerlendirme)