Database Reference
In-Depth Information
Some of the colors contain an & character, which is special in HTML and must be
HTML-encoded when placed into list elements. (We'll perform list element en‐
coding as a matter of habit. Those values illustrate why it's a good idea to get in that
habit.)
• The list of legal figurine sizes in the size column of the cow_order table. The col‐
umn is represented as an ENUM , so the permitted and default values can be obtained
from INFORMATION_SCHEMA :
mysql> SELECT COLUMN_TYPE, COLUMN_DEFAULT
-> FROM INFORMATION_SCHEMA.COLUMNS
-> WHERE TABLE_SCHEMA='cookbook' AND TABLE_NAME='cow_order'
-> AND COLUMN_NAME='size';
+--------------------------------+----------------+
| COLUMN_TYPE | COLUMN_DEFAULT |
+--------------------------------+----------------+
| enum('small','medium','large') | medium |
+--------------------------------+----------------+
• The list of state names and abbreviations. These are stored in the states table:
mysql> SELECT abbrev, name FROM states ORDER BY name;
+--------+----------------+
| abbrev | name |
+--------+----------------+
| AL | Alabama |
| AK | Alaska |
| AZ | Arizona |
| AR | Arkansas |
| CA | California |
| CO | Colorado |
The number of choices varies for each list just described: 3 figurine sizes, 7 colors, and
50 states. The differing numbers of choices lead to different decisions about how to
represent the lists in a form:
• The figurine size values are best represented as a set of radio buttons or a pop-up
menu; a scrolling list is unnecessary because the number of choices is small.
• The set of colors can reasonably be displayed using any of the single-pick element
types; it's small enough that a set of radio buttons wouldn't take a lot of space, but
large enough that you may want to enable scrolling—particularly if you make ad‐
ditional colors available.
• The list of states has more items than feasible to present as a set of radio buttons.
It's more reasonably displayed as a pop-up menu or scrolling list.
The following discussion describes the HTML syntax for these types of elements and
then shows how to generate them from within scripts:
Search WWH ::




Custom Search