質問編集履歴

2

修正

2022/01/25 01:12

投稿

tom_beginner
tom_beginner

スコア2

test CHANGED
File without changes
test CHANGED
@@ -49,5 +49,5 @@
49
49
 
50
50
  $t_colorに値が入っている時
51
51
  ```
52
- Fatal error: Uncaught Error: Call to a member function bind_param() on bool in
52
+ Fatal error: Uncaught Error: Call to a member function fetch_all() on bool in
53
53
  ```

1

追記

2022/01/25 01:08

投稿

tom_beginner
tom_beginner

スコア2

test CHANGED
File without changes
test CHANGED
@@ -27,11 +27,27 @@
27
27
  ?>
28
28
  ```
29
29
 
30
- ### 試したこと
30
+ ### 変更後
31
+ ```PHP
32
+ $sql = "SELECT * FROM it where kind like 'トップス'" ;
33
+ if(empty($t_color)){
34
+ $stmt = $dbh->query($sql);
35
+ }
36
+ else{
37
+ $sql.="and where color like '$t_color'";
38
+ $stmt = $dbh->query($sql);
39
+ }
40
+ $rows=$stmt->fetch_all(MYSQLI_ASSOC);
41
+ print_r($rows);
42
+ ```
31
43
 
32
- ここに問題に対して試したことを記載してください。
44
+ [結果]
45
+ $t_colorが空の時
46
+ ```
47
+ Array ( [0] => Array ( [meisho] => トップス1 [season] => 春 [kind] => トップス [tops] => ニット [botom] => [auter] => [onep] => [inone] => [color] => 白 [nagasa] => ミドル [sode] => 十分丈 [gara] => 無地 ) [1] => Array ( [meisho] => トップス2 [season] => 夏 [kind] => トップス [tops] => Tシャツ [botom] => [auter] => [onep] => [inone] => [color] => 青 [nagasa] => ミドル [sode] => 半袖 [gara] => プリント ) [2] => Array ( [meisho] => トップス3 [season] => 秋 冬 [kind] => トップス [tops] => カーディガン [botom] => [auter] => [onep] => [inone] => [color] => 黄色 [nagasa] => ミドル [sode] => 十分丈 [gara] => 無地 ) )
48
+ ```
33
49
 
34
- ### 補足情報(FW/ツールのバージョンなど)
35
-
36
- ここより詳細な情報を記載しくださ
50
+ $t_color値が入っている時
37
-
51
+ ```
52
+ Fatal error: Uncaught Error: Call to a member function bind_param() on bool in
53
+ ```