1select t2.sid,t2.sname
2,case hweekday when1then'○'elsenullendas mon
3,case hweekday when2then'○'elsenullendas tue
4,case hweekday when3then'○'elsenullendas wed
5,case hweekday when4then'○'elsenullendas thu
6,case hweekday when5then'○'elsenullendas fri
7,case hweekday when6then'○'elsenullendas sat
8,case hweekday when7then'○'elsenullendas sun
9from holiday as t1
10rightjoin shop as t2 on t1.sid=t2.sid
(命題のデータ表示のとおり)
PHP側はこう
PHP
1<?PHP2$h=filter_input(INPUT_POST,'h',FILTER_VALIDATE_INT,["options"=>["min_range"=>1,"max_range"=>7],"flags"=>FILTER_REQUIRE_ARRAY]);34$sql=<<<eof5select t2.sid,t2.sname
6,case hweekday when 1 then '○' else null end as mon
7,case hweekday when 2 then '○' else null end as tue
8,case hweekday when 3 then '○' else null end as wed
9,case hweekday when 4 then '○' else null end as thu
10,case hweekday when 5 then '○' else null end as fri
11,case hweekday when 6 then '○' else null end as sat
12,case hweekday when 7 then '○' else null end as sun
13from holiday as t1
14right join shop as t2 on t1.sid=t2.sid
15where 1
1617eof;1819$data=[];20if(!is_null($h)){21if(in_array(false,$h)!==false){22$sql.="and 0 ";23}else{24$sql.="and hweekday in(".implode(",",array_fill(0,count($h),"?")).") ";25}26}2728print$sql."<br>";29var_dump($data);3031/*
32try{
33 $pdo = new PDO($dsn, $user,$password);
34 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
35 $stmt = $pdo->prepare($sql);
36 $stmt->execute($data);
37 $rows=$stmt->fetchAll(PDO::FETCH_ASSOC);
38 print_r($rows);
39}catch(PDOException $e){
40 die($e->getMessage());
41}
42 */43?>444546<formmethod="post">47<p>【定休日】</p>48<label><inputtype="checkbox"name="h[]"value="99">test用不正データ</label>49<label><inputtype="checkbox"name="h[]"value="1">月</label>50<label><inputtype="checkbox"name="h[]"value="2">火</label>51<label><inputtype="checkbox"name="h[]"value="3">水</label>52<label><inputtype="checkbox"name="h[]"value="4">木</label>53<label><inputtype="checkbox"name="h[]"value="5">金</label>54<label><inputtype="checkbox"name="h[]"value="6">土</label>55<label><inputtype="checkbox"name="h[]"value="7">日</label>56<inputtype="submit"value="検索する">57</form>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/10 00:47
2019/02/10 01:59