Devam Ediyor

Dynamically create a mysql select query

Hi,

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.

Thanks

Paul

Beceriler: MySQL, PHP

Daha fazlasını görün: create query dynamically mysql, n query, data structure array, create table php, array data structure, select, query table, mysql query, data query, 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, mysql query php, create list data php, mysql join

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

Proje NO: #707338

Seçilen:

VALUEONWEB

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 fazlası

0 gün içinde 30$ USD
(213 Değerlendirme)
7.9