DBから条件と合致するものをとりだしたいのか、入力が特定の条件なのか
わからない質問ですね。
たとえばこう
PHP
1<?PHP
2$c=filter_input(INPUT_GET,"c",FILTER_DEFAULT,FILTER_REQUIRE_ARRAY);
3if(is_array($c) and count($c)==1 and in_array("やさしい",$c)!==false){
4 print "やさしいだけの男<br>";
5}
6?>
7<form method="get">
8<label><input type="checkbox" name="c[]" value="やさしい">やさしい</label><br>
9<label><input type="checkbox" name="c[]" value="楽しい">楽しい</label><br>
10<label><input type="checkbox" name="c[]" value="話が面白い">話が面白い</label><br>
11<label><input type="checkbox" name="c[]" value="スポーツ好き">スポーツ好き</label><br>
12<label><input type="checkbox" name="c[]" value="料理好き">料理好き</label><br>
13<label><input type="checkbox" name="c[]" value="オンオフはっきり">オンオフはっきり</label><br>
14<input type="submit" value="check">
15</form>
mysql側の処理
データの持ち方はこうしてください
SQL
1create table user (uid int primary key ,uname varchar(30));
2insert into user values(1,'佐藤'),(2,'鈴木'),(3,'田中'),(4,'中村');
3
4create table tokucho(tid int primary key,tname varchar(30));
5insert into tokucho values(1,'やさしい'),(2,'楽しい'),(3,'話が面白い'),(4,'スポーツ好き'),(5,'料理好き'),(6,'オンオフはっきり');
6
7create table user_tokucho (utid int primary key,uid int not null,tid int not null,unique(uid,tid));
8insert into user_tokucho values
9(1,1,1),(2,1,2),(3,2,2),(4,2,3),(5,2,4),(6,2,5),(7,2,6),(8,3,1),(9,4,2);
そうすると個人ごとの特徴の一覧がこうなります
SQL
1select t1.uname,group_concat(t3.tname) as tnames
2from user as t1
3inner join user_tokucho as t2 on t1.uid=t2.uid
4inner join tokucho as t3 on t2.tid=t3.tid
5group by uname
特徴が「やさしい」だけなのでこれを絞り込みます
SQL
1select t1.uname,group_concat(t3.tname) as tnames
2from user as t1
3inner join user_tokucho as t2 on t1.uid=t2.uid
4inner join tokucho as t3 on t2.tid=t3.tid
5group by uname
6having tnames='やさしい'
ちゃんとやるならこう
SQL
1select * from user as t1 where exists(
2select 1 from user_tokucho as t2
3group by uid
4having count(*)=1
5and sum(tid=(select tid from tokucho where tname='やさしい'))=1
6and uid=t1.uid)