回答編集履歴

1

追記

2016/04/22 13:19

投稿

退会済みユーザー
test CHANGED
@@ -15,3 +15,53 @@
15
15
  </select>
16
16
 
17
17
  ```
18
+
19
+
20
+
21
+ ---
22
+
23
+
24
+
25
+ ```html
26
+
27
+ <?php
28
+
29
+ function h($str)
30
+
31
+ {
32
+
33
+ return htmlspecialchars($str, ENT_QUOTES);
34
+
35
+ }
36
+
37
+
38
+
39
+ $recordSet = mysql_query("SELECT * FROM city ORDER BY city_id");
40
+
41
+ ?>
42
+
43
+ <select name="schoolcity">
44
+
45
+ <option value="">市</option>
46
+
47
+ <option value="">---------</option>
48
+
49
+ <?php while ($LowCity = mysql_fetch_assoc($recordSet)) : ?>
50
+
51
+ <?php if (条件式) : ?>
52
+
53
+ <option value="<?= h($LowCity['city_id']) ?>" class="<?= h($LowCity['city_id']) ?>" selected="selected"><?= h($LowCity['city_name']) ?></option>
54
+
55
+ <?php else : ?>
56
+
57
+ <option value="<?= h($LowCity['city_id']) ?>" class="<?= h($LowCity['city_id']) ?>"><?= h($LowCity['city_name']) ?></option>
58
+
59
+ <?php endif; ?>
60
+
61
+ <?php endwhile; ?>
62
+
63
+ </select>
64
+
65
+ ```
66
+
67
+