tailieunhanh - PHP 5/MySQL Programming- P47

PHP 5/MySQL Programming- P47:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 208 PHP 5 MySQL Programming for the Absolute Beginner center td tr table form HERE end showTest Although the code is long almost all of it is pure HTML. The PHP part selects HTML files and places them in the select group. This code fragment uses the preg_grep to select filenames ending in HTML and creates an option tag for that file. Note that I stripped out the .html part of the filename because I won t need it. It would complicate some of the code coming up in the takeQuiz program. Showing the Edit List The showEdit function works a lot like showTest listing the system s master files. Although it is often exactly the same as the list of tests it won t always be the same some master files may not have been made into HTML files. function showEdit let user select a master file to edit global theFiles get only quiz master files testFiles preg_grep mas theFiles edit a quiz print HERE form action method post table border 1 width 400 tr td colspan 2 center h3 Edit a quiz h3 center td tr 209 tr td Administrative Password td td input type password name password value td tr tr td Quiz td td select name editFile option value new new quiz option HERE foreach testFiles as myFile fileBase substr myFile 0 strlen myFile - 4 print option value myFile fileBase option n end foreach Chapter 6 Working th Files print HERE select td tr tr td colspan 2 center input type submit value go center td tr table form HERE end showEdit 210 PHP 5 MySQL Programming for the Absolute Beginner The showEdit function is just like showQuiz but the form points to the program and the file list is based on those files ending in mas. There s one other subtle but important difference Look at the code for the select element and see a new quiz option. If the user chooses this option the editQuiz function won t try to load a quiz file into memory but sets up for a new quiz instead. Showing the Log List The last segment is meant for the quiz administrator. It allows the user with .