teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

コード編集

2017/07/28 03:05

投稿

tagu5959
tagu5959

スコア41

title CHANGED
File without changes
body CHANGED
@@ -4,13 +4,17 @@
4
4
 
5
5
  【やりたいこと】
6
6
  searchform.php で
7
+ ```php
7
- <code><input type="text" name="s" id="s" placeholder="検索" />//検索ワード
8
+ <input type="text" name="s" id="s" placeholder="検索" />//検索ワード
8
9
  <input type="text" name="product_number">//品番
9
- <input type="radio" name="product_category">//カテゴリ</code>
10
+ <input type="radio" name="product_category">//カテゴリ
10
11
 
12
+ ```
13
+
11
14
  という項目がありまして、search.phpに
12
15
 
16
+ ```php
13
- <code>if($_GET['s']){$s = $_GET['s'];}//フリーワード
17
+ if($_GET['s']){$s = $_GET['s'];}//フリーワード
14
18
  if($_GET['product_number']){$product_number = $_GET['product_number'];}
15
19
  if($_GET['product_category']){$product_category = $_GET['product_category'];}
16
20
 
@@ -31,8 +35,10 @@
31
35
  'relation' => 'AND'
32
36
  )
33
37
  )
34
- </code>
38
+ ```
35
39
 
40
+
41
+
36
42
  という形でsearchform.phpから全部の項目が送信された場合は動くのですが、どれかひとつでも値がない(ラジオボタンのチェックがない)場合に検索結果が0件になってしまいます。
37
43
  値が送信されたもののみでAND検索を行うことは可能でしょうか?
38
44
 

2

コード編集

2017/07/28 03:05

投稿

tagu5959
tagu5959

スコア41

title CHANGED
File without changes
body CHANGED
@@ -4,13 +4,13 @@
4
4
 
5
5
  【やりたいこと】
6
6
  searchform.php で
7
- ```<input type="text" name="s" id="s" placeholder="検索" />//検索ワード
7
+ <code><input type="text" name="s" id="s" placeholder="検索" />//検索ワード
8
8
  <input type="text" name="product_number">//品番
9
- <input type="radio" name="product_category">//カテゴリ```
9
+ <input type="radio" name="product_category">//カテゴリ</code>
10
10
 
11
11
  という項目がありまして、search.phpに
12
12
 
13
- ```if($_GET['s']){$s = $_GET['s'];}//フリーワード
13
+ <code>if($_GET['s']){$s = $_GET['s'];}//フリーワード
14
14
  if($_GET['product_number']){$product_number = $_GET['product_number'];}
15
15
  if($_GET['product_category']){$product_category = $_GET['product_category'];}
16
16
 
@@ -30,7 +30,8 @@
30
30
  ),
31
31
  'relation' => 'AND'
32
32
  )
33
- )```
33
+ )
34
+ </code>
34
35
 
35
36
  という形でsearchform.phpから全部の項目が送信された場合は動くのですが、どれかひとつでも値がない(ラジオボタンのチェックがない)場合に検索結果が0件になってしまいます。
36
37
  値が送信されたもののみでAND検索を行うことは可能でしょうか?

1

コードの編集

2017/07/28 03:04

投稿

tagu5959
tagu5959

スコア41

title CHANGED
File without changes
body CHANGED
@@ -4,13 +4,13 @@
4
4
 
5
5
  【やりたいこと】
6
6
  searchform.php で
7
- <input type="text" name="s" id="s" placeholder="検索" />//検索ワード
7
+ ```<input type="text" name="s" id="s" placeholder="検索" />//検索ワード
8
8
  <input type="text" name="product_number">//品番
9
- <input type="radio" name="product_category">//カテゴリ
9
+ <input type="radio" name="product_category">//カテゴリ```
10
10
 
11
11
  という項目がありまして、search.phpに
12
12
 
13
- if($_GET['s']){$s = $_GET['s'];}//フリーワード
13
+ ```if($_GET['s']){$s = $_GET['s'];}//フリーワード
14
14
  if($_GET['product_number']){$product_number = $_GET['product_number'];}
15
15
  if($_GET['product_category']){$product_category = $_GET['product_category'];}
16
16
 
@@ -30,7 +30,7 @@
30
30
  ),
31
31
  'relation' => 'AND'
32
32
  )
33
- )
33
+ )```
34
34
 
35
35
  という形でsearchform.phpから全部の項目が送信された場合は動くのですが、どれかひとつでも値がない(ラジオボタンのチェックがない)場合に検索結果が0件になってしまいます。
36
36
  値が送信されたもののみでAND検索を行うことは可能でしょうか?