回答編集履歴

4

修正

2019/02/07 03:18

投稿

mayoi_maimai
mayoi_maimai

スコア1583

test CHANGED
@@ -158,7 +158,7 @@
158
158
 
159
159
  </tr>
160
160
 
161
- <? endforeach: ?>
161
+ <?php endforeach: ?>
162
162
 
163
163
  </tbody>
164
164
 

3

修正

2019/02/07 03:18

投稿

mayoi_maimai
mayoi_maimai

スコア1583

test CHANGED
@@ -82,9 +82,11 @@
82
82
 
83
83
 
84
84
 
85
+ // 小計
86
+
85
87
  $itemTotal += $products[$i]['Subtotal'];
86
88
 
87
- $i++;
89
+ $i++;
88
90
 
89
91
  }
90
92
 

2

再編集

2019/02/07 03:17

投稿

mayoi_maimai
mayoi_maimai

スコア1583

test CHANGED
@@ -83,6 +83,8 @@
83
83
 
84
84
 
85
85
  $itemTotal += $products[$i]['Subtotal'];
86
+
87
+ $i++;
86
88
 
87
89
  }
88
90
 

1

一部編集

2019/02/07 03:14

投稿

mayoi_maimai
mayoi_maimai

スコア1583

test CHANGED
@@ -62,6 +62,8 @@
62
62
 
63
63
  // $_SESSION['cart'][商品id]となっているので、1件ずつ商品idを取り出し商品情報を取得し、$products配列に入れる
64
64
 
65
+ $i=0;
66
+
65
67
  foreach($_SESSION['cart'] as $key => $value){
66
68
 
67
69
  $sql = "SELECT * FROM EC where id = ".$key."";
@@ -70,17 +72,17 @@
70
72
 
71
73
 
72
74
 
73
- $products[] = $stmh->fetch(PDO::FETCH_ASSOC);
75
+ $products[$i] = $stmh->fetch(PDO::FETCH_ASSOC);
74
76
 
75
- $products[]['item-count'] = $value['cnt'];
77
+ $products[$i]['item-count'] = $value['cnt'];
76
78
 
77
- $products[]['item-size'] = $value['size'];
79
+ $products[$i]['item-size'] = $value['size'];
78
80
 
79
- $products[]['Subtotal'] = $value['cnt'] * $products[]['price'];
81
+ $products[$i]['Subtotal'] = $value['cnt'] * $products[$i]['price'];
80
82
 
81
83
 
82
84
 
83
- $itemTotal += $products[]['Subtotal'];
85
+ $itemTotal += $products[$i]['Subtotal'];
84
86
 
85
87
  }
86
88