質問編集履歴

2

コードを追加しました

2017/04/23 01:30

投稿

mattsu
mattsu

スコア10

test CHANGED
File without changes
test CHANGED
@@ -259,3 +259,141 @@
259
259
 
260
260
 
261
261
  以上、宜しくお願いします。
262
+
263
+
264
+
265
+ ーーーーーーーーーーーーー追記------------
266
+
267
+ reward_tha.phpのページに質問の答えになりそうなものがあるとアドバイス頂いたので掲載しておきます。
268
+
269
+
270
+
271
+ ```ここに言語を入力
272
+
273
+ <?php
274
+
275
+ if ($_SERVER["REQUEST_METHOD"] == "POST") {
276
+
277
+ $koudou = $_POST["action"];
278
+
279
+ $point = $_POST["point"];
280
+
281
+ }
282
+
283
+ ?>
284
+
285
+ <html lang="ja">
286
+
287
+ <head>
288
+
289
+ <meta charset="UTF-8">
290
+
291
+ <title>確認フォーム</title>
292
+
293
+ <link rel="stylesheet" href="style.css">
294
+
295
+ </head>
296
+
297
+ <body>
298
+
299
+ <div>
300
+
301
+ <p>登録ありがとうございました。</p>
302
+
303
+ <div>
304
+
305
+ <div>
306
+
307
+ <label>行動</label>
308
+
309
+ <p><?php echo $koudou; ?></p>
310
+
311
+ </div>
312
+
313
+ <div>
314
+
315
+ <label>ポイント</label>
316
+
317
+ <p><?php echo $point; ?></p>
318
+
319
+ </div>
320
+
321
+ </div>
322
+
323
+ <?php $dbcon = pg_connect("dbname=ossdb user=postgres password=password");
324
+
325
+ if (!$dbcon) {
326
+
327
+ die("<hr>pg_connect 失敗<hr>");
328
+
329
+ }
330
+
331
+ $sql1 = "SELECT total FROM routine order by day desc limit 1";
332
+
333
+ $result1 = pg_query ($dbcon, $sql1);
334
+
335
+ if (!$result1) {
336
+
337
+ pg_last_error($dbcon);
338
+
339
+ die( "pg_exec 失敗<hr>" );
340
+
341
+ }
342
+
343
+ $numrows1 = pg_num_rows($result1);
344
+
345
+ $fnum1 = pg_num_fields($result1);
346
+
347
+ for ($i1 = 0; $i1 < $numrows1; $i1++) {
348
+
349
+ $row1 = pg_fetch_object($result1, $i1);
350
+
351
+ echo "<tr align='center'>";
352
+
353
+ for ($x1 = 0; $x1 < $fnum1; $x1++) {
354
+
355
+ $fieldname1 = pg_field_name($result1, $x1);
356
+
357
+
358
+
359
+ $tasu = htmlspecialchars($row1->$fieldname1);
360
+
361
+
362
+
363
+ }
364
+
365
+
366
+
367
+ }
368
+
369
+ $total = ($point + $tasu);
370
+
371
+
372
+
373
+ $sql2 = "insert into routine values (now(),'','$koudou','$point','$total')";
374
+
375
+
376
+
377
+ $result2 = pg_query ($dbcon, $sql2);
378
+
379
+ if (!$result2) {
380
+
381
+ pg_last_error($dbcon);
382
+
383
+ die( "pg_exec 失敗だよ<hr>");
384
+
385
+ }
386
+
387
+ pg_close($dbcon);
388
+
389
+ ?>
390
+
391
+
392
+
393
+ <a href="toppage.php">トップページへ</a>
394
+
395
+
396
+
397
+
398
+
399
+ ```

1

誤って途中送信したので書き加えました

2017/04/23 01:30

投稿

mattsu
mattsu

スコア10

test CHANGED
File without changes
test CHANGED
@@ -246,4 +246,16 @@
246
246
 
247
247
  2 データベースから削除する場合
248
248
 
249
- delete from
249
+ delete from 表明
250
+
251
+ where 条件
252
+
253
+ だと思うのですが
254
+
255
+
256
+
257
+ プルダウン型のメニューから相手が選んだものを条件にする方法が分かりません。
258
+
259
+
260
+
261
+ 以上、宜しくお願いします。