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

質問編集履歴

1

無駄なコードを消去しました。

2016/07/14 07:06

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -69,9 +69,7 @@
69
69
 
70
70
  $vid = (string)filter_input(INPUT_POST, 'vid');
71
71
  $nm = (string)filter_input(INPUT_POST, 'nm');
72
- $ndt = (string)filter_input(INPUT_POST, 'ndt');
72
+
73
- $ndt2 = (string)filter_input(INPUT_POST, 'ndt2');
74
-
75
73
  $dsn ='mysql:dbname=kadai;host=localhost';
76
74
  $user ='root';
77
75
  $password='';
@@ -87,17 +85,9 @@
87
85
  if ($nm != "" )
88
86
  {
89
87
  $sql .= " and name like '%$nm%' ";
90
- }
88
+
91
- if ($ndt != "" )
89
+ if(empty($vid)&& empty($nm))
92
90
  {
93
- $sql .= " and ndate >= '$ndt' ";
94
- }
95
- if ($ndt2 != "" )
96
- {
97
- $sql .= " and ndate <= '$ndt2' ";
98
- }
99
- if(empty($vid)&& empty($nm) && empty($ndt)&& empty($ndt2))
100
- {
101
91
  print "何も入力されていません。<br/><br/>";
102
92
 
103
93
  print'<input type="button"onclick="history.back()"value="戻る">';
@@ -108,8 +98,6 @@
108
98
 
109
99
  $data[]=$vid;
110
100
  $data[]=$nm;
111
- $data[]=$ndt;
112
- $data[]=$ndt2;
113
101
  $stmt->execute($data);
114
102
  $count = $stmt->rowCount();
115
103
 
@@ -230,16 +218,9 @@
230
218
  {
231
219
  $sql .= " and name like '%$nm%' ";
232
220
  }
221
+
233
- if ($ndt != "" )
222
+ if(empty($vid)&& empty($nm))
234
223
  {
235
- $sql .= " and ndate >= '$ndt' ";
236
- }
237
- if ($ndt2 != "" )
238
- {
239
- $sql .= " and ndate <= '$ndt2' ";
240
- }
241
- if(empty($vid)&& empty($nm) && empty($ndt)&& empty($ndt2))
242
- {
243
224
  print "何も入力されていません。<br/><br/>";
244
225
 
245
226
  print'<input type="button"onclick="history.back()"value="戻る">';
@@ -250,8 +231,6 @@
250
231
 
251
232
  $data[]=$vid;
252
233
  $data[]=$nm;
253
- $data[]=$ndt;
254
- $data[]=$ndt2;
255
234
  $stmt2->execute($data);
256
235
 
257
236
  print'<table class = "info" border=1>';