You next build the (Web server certificate) table in HTML, and

You next build the table in HTML, and insert values into the appropriate places as defaults. This is how you fill in the fields with character data. Note how the script checks to see if the variable is set before echoing it to the page. If it didn t, and the error reporting for PHP was set to E_ALL, there might be a warning printed to the screen if $ch didn t contain a value. Checking is usually a good idea if you aren t certain a variable will be set. Character Name: >

Now you build the Powers select field. As the script loops through each power in the $pwrlist array (which contains all powers), it concatenates the $powers array value for that power ( selected ). If that power s key (from $pwrlist) doesn t exist in the $powers array, $powers[$key] will simply be blank instead of selected. In this way, the script builds a field of all powers where the character s chosen powers are selected in the list. Neato, huh? Powers:
(Ctrl-click to
select multiple
powers)

Note the [] in the select name attribute. That is necessary for PHP to recognize the variable as an array when it gets POSTed to the next page. This is a requirement for any field that might post with multiple values. The following code creates a set of radio buttons for good and evil. The character s alignment is selected with the checked attribute. > good
> evil

322 Chapter 10
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Leave a Reply