サンプルコード
html
1<?php
2$arr = array(
3 0 => 'なし'
4 , 1 => '一個'
5 , 2 => '二個'
6 , 3 => '三個'
7 , 4 => '四個'
8);
9?><!DOCTYPE HTML>
10<html lang="ja">
11 <head>
12 <meta charset="UTF-8">
13 <title></title>
14 </head>
15 <body>
16 <form action="" method="post">
17 <select name="count">
18 <?php foreach ($arr as $key => $val): ?>
19 <option value="<?= $key; ?>"><?= $val; ?></option>
20 <?php endforeach; ?>
21 </select>
22 <button>送信</button>
23 </form>
24 <div>
25 <p>個数 : <?= $arr[filter_input(INPUT_POST, 'count')]; ?></p>
26 </div>
27 </body>
28</html>
html
1<?php
2/**
3 * index.php
4 */
5require 'common.php';
6?><!DOCTYPE HTML>
7<html lang="ja">
8 <head>
9 <meta charset="UTF-8">
10 <title></title>
11 </head>
12 <body>
13 <form action="confirm.php" method="post">
14 <select name="count">
15 <?php foreach ($arr as $key => $val): ?>
16 <option value="<?= $key; ?>"><?= $val; ?></option>
17 <?php endforeach; ?>
18 </select>
19 <button>送信</button>
20 </form>
21 </body>
22</html>
html
1<?php
2/**
3 * confirm.php
4 */
5require 'common.php';
6?>
7<!DOCTYPE HTML>
8<html lang="ja">
9 <head>
10 <meta charset="UTF-8">
11 <title></title>
12 </head>
13 <body>
14 <div>
15 <p>個数 : <?= $arr[filter_input(INPUT_POST, 'count')]; ?></p>
16 </div>
17 </body>
18</html>
html
1<?php
2
3/**
4 * common.php
5 */
6$arr = array(
7 0 => 'なし'
8 , 1 => '一個'
9 , 2 => '二個'
10 , 3 => '三個'
11 , 4 => '四個'
12);
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/13 05:51
2016/11/13 06:08
2016/11/13 07:47
退会済みユーザー
2016/11/13 07:53
2016/11/13 14:12