回答編集履歴
1
追記
test
CHANGED
@@ -9,3 +9,95 @@
|
|
9
9
|
の、意図がわかりません。
|
10
10
|
|
11
11
|
商品はidで管理するものなので最初からpostする段階でidを受け取ってくださいとしか・・・
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
# 流れ
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
- nyuryoku.php
|
20
|
+
|
21
|
+
```PHP
|
22
|
+
|
23
|
+
<style>
|
24
|
+
|
25
|
+
.suryo{text-align:right}
|
26
|
+
|
27
|
+
</style>
|
28
|
+
|
29
|
+
<form method="post" action="kakunin.php">
|
30
|
+
|
31
|
+
<table>
|
32
|
+
|
33
|
+
<tr>
|
34
|
+
|
35
|
+
<td><label><input type="checkbox" name="id[]" value="0" checked>hoge</label></td>
|
36
|
+
|
37
|
+
<td><input type="text" name="suryo[0]" class="suryo" value="100"></td>
|
38
|
+
|
39
|
+
</tr>
|
40
|
+
|
41
|
+
<td><label><input type="checkbox" name="id[]" value="1">fuga</label></td>
|
42
|
+
|
43
|
+
<td><input type="text" name="suryo[1]" class="suryo" value="200"></td>
|
44
|
+
|
45
|
+
</tr>
|
46
|
+
|
47
|
+
<td><label><input type="checkbox" name="id[]" value="2" checked>piyo</label></td>
|
48
|
+
|
49
|
+
<td><input type="text" name="suryo[2]" class="suryo" value="0"></td>
|
50
|
+
|
51
|
+
</tr>
|
52
|
+
|
53
|
+
</table>
|
54
|
+
|
55
|
+
<input type="submit" value="go">
|
56
|
+
|
57
|
+
</form>
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
- kakunin.php
|
62
|
+
|
63
|
+
```PHP
|
64
|
+
|
65
|
+
<?PHP
|
66
|
+
|
67
|
+
session_start();
|
68
|
+
|
69
|
+
$id=filter_input(INPUT_POST,"id",FILTER_VALIDATE_INT,FILTER_REQUIRE_ARRAY);
|
70
|
+
|
71
|
+
$suryo=filter_input(INPUT_POST,"suryo",FILTER_VALIDATE_INT,FILTER_REQUIRE_ARRAY);
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
$cart=[];
|
76
|
+
|
77
|
+
foreach($id as $val){
|
78
|
+
|
79
|
+
$cart[]=["id"=>$val,"suryo"=>$suryo[$val]];
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
$_SESSION["cart"]=$cart;
|
84
|
+
|
85
|
+
?>
|
86
|
+
|
87
|
+
<a href="keishou.php">継承データ確認</a>
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
- keishou.php
|
94
|
+
|
95
|
+
```PHP
|
96
|
+
|
97
|
+
<?PHP
|
98
|
+
|
99
|
+
session_start();
|
100
|
+
|
101
|
+
print_r($_SESSION["cart"]);
|
102
|
+
|
103
|
+
```
|