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

質問編集履歴

4

修正

2017/06/28 13:15

投稿

YukaSaku
YukaSaku

スコア52

title CHANGED
File without changes
body CHANGED
@@ -254,12 +254,12 @@
254
254
  name |VARCHAR(50)|Product name.
255
255
  description|VARCHAR(500)|The description of product.|
256
256
  price |DECIMAL(7,2)|The price of product.|
257
- category_id|INT(10)|The category ID of product.|
257
+ category_id|INT(5)|The category ID of product.|
258
258
 
259
259
  Table Name: **product_category**
260
260
  |Column Name|Type|Description|
261
261
  |:--|:--:|--:|
262
- category_id|INT(10)|Category ID number.AUTO_INCREMENT. Primary key.Unique.
262
+ category_id|INT(5)|Category ID number.AUTO_INCREMENT. Primary key.Unique.
263
263
  category|VARCHAR(100)|The name of the category.|
264
264
 
265
265
  Table Name: **product_img**
@@ -268,4 +268,4 @@
268
268
  catalog_id|INT(5)|Catalog ID number.AUTO_INCREMENT. Primary key.Unique.
269
269
  path|VARCHAR(300)|the small picture path.
270
270
  path_small|VARCHAR(300)|the picture path.
271
- category_id|INT(10)|Category ID number.
271
+ category_id|INT(5)|Category ID number.

3

訂正箇所がありました

2017/06/28 13:15

投稿

YukaSaku
YukaSaku

スコア52

title CHANGED
File without changes
body CHANGED
@@ -254,7 +254,7 @@
254
254
  name |VARCHAR(50)|Product name.
255
255
  description|VARCHAR(500)|The description of product.|
256
256
  price |DECIMAL(7,2)|The price of product.|
257
- category_id|VARCHAR(10)|The category ID of product.|
257
+ category_id|INT(10)|The category ID of product.|
258
258
 
259
259
  Table Name: **product_category**
260
260
  |Column Name|Type|Description|
@@ -268,4 +268,4 @@
268
268
  catalog_id|INT(5)|Catalog ID number.AUTO_INCREMENT. Primary key.Unique.
269
269
  path|VARCHAR(300)|the small picture path.
270
270
  path_small|VARCHAR(300)|the picture path.
271
- category_id|INT(5)|Category ID number.
271
+ category_id|INT(10)|Category ID number.

2

プログラムを少しだけ変えてみました。

2017/06/28 00:11

投稿

YukaSaku
YukaSaku

スコア52

title CHANGED
File without changes
body CHANGED
@@ -71,8 +71,8 @@
71
71
  <select name="num">
72
72
  <?php
73
73
  for ($i = 1; $i <= 9; $i++) {
74
- echo "<option>$i</option>";
74
+ echo "<option value='" . $i . "'>".$i."</option>";
75
- $quantity = $i;
75
+ $quantity = $i;
76
76
  }
77
77
  ?>
78
78
  </select>
@@ -220,7 +220,7 @@
220
220
  if (isset($_SESSION['cart'][$this->numberOfItems()]['id'])) {
221
221
  // 注文数を増やす
222
222
  $_SESSION['cart'][$this->numberOfItems()]['item'] = $items; //TODO: Item returned from db;
223
- $_SESSION['cart'][$this->numberOfItems()]['quantity'] += $_POST['qty']; //TODO: Item returned from db;
223
+ $_SESSION['cart'][$this->numberOfItems()]['quantity'] += $_POST['num']; //TODO: Item returned from db;
224
224
  }
225
225
  else { //新規注文
226
226
  $_SESSION['cart'][$this->numberOfItems()]['item'] = $items;

1

書式の改善

2017/06/27 20:49

投稿

YukaSaku
YukaSaku

スコア52

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  小さな ECサイトのカート部分で、ユーザーが商品を選んだ際にその商品情報をDBに取りに行って、ユーザーがドロップダウンから選択した商品個数とともに、表示をしたいと思っています。
2
- なるべくたくさんのSESSIONを使わないように、商品が選ばれた時(product_get.php)に、DBに見にいく(cart.inc)ようにしています。
2
+ 商品が選ばれた時(product_get.php)に、DBに見にいく(cart.inc)ようにしています。
3
3
 
4
4
  結果は以下のように表示されます。
5
5
  ```php