H headers, 264 HERE token, 80 hidden form fields, 45, 117 Hi Jacob program, 23–25 Hi User progra m, 71–73 htdocs directory, 8, 276 httdocs subdirectory, 9–10 HTML (hypertext markup language) associative arrays, 150–151 forms, 33–36 library module, 409–413 multidimensional arrays, 146–147 Petals program, 88–89, 94 Poker Dice program, 117–118 story program, 48–51 quiz program, 216–220 HTTP (hypertext transfer protocol), 114 I if else clauses, 68 if statements Ace program, 59–61 combining form and results, 71–73 comparison operators, 62 creating, 62–63 multiple-condition, 68 imageIndex program, 194–196 images, printing, 58–59 include command, 231, 281, 396–397 inconsistent data, 361–362 indenting lines, 80 index.html page, 8 inheritance, 249, 257–260 inner joins, 376 inserting table values, 311–312 installation Apache, 6–10 development environment, 5–6 MySQL, 303–304 PHP , 10–11 PHP-Nuke, 276 using existing server, 4 instructions (syntax), 27 integers, 32 Internet Information Server (IIS), 6 interpolaation speed, 159 troubleshooting, 175 variable, 58 interpreters, 114 item class, 283 J joins conditions, 375–376 creating, 373–374 using, 373 WHERE clause, 374–375 L LAMP (Linux, Apache, MySQL, and PHP), 5 less than symbol (<), 62 library module connection, 408 creating CSS style, 406–407 variables, 407–408 field types, 418–419 foreign keys, 419–420 forms generic edit record, 314–415 smarter edit record, 415–418 HTML tables, 409–413 list boxes, 426 mainButton program, 427 overview, 392–393, 396–397 primary key, 419 quick lists, 408–409 records addition, 422–425 deletion, 422 processing, 425 updates, 420–422 regular fields, 420 LIKE clause, 326 line separation character (:), 182 line termination character (;), 27 link tables, 376–380 list boxes adventure game, 355 library module, 426 multiple selection, 45 listed fieelds, 362–363 list() function, 203 lists creating, 264–265 superHTML, 237–239 ad hoc, 239 basic, 238 specialized, 239 listSegments program, 348–350 loading files, (CSS), 191–192 loadSonnet program, 189–192 433 I n d e x localhost address, 7 log files quiz results, 224–225 viewing, 225–226 logic building, Word Search, 163–164 looping structures, 95 combining with arrays, 111–113 examining array’s contents, 109–110 fillBoard() function, 167, 167–168 for loops counting with, 96–100 examining array’s contents, 109–111 modifying, 100–103 versus foreach loops, 137 Word Search program, 166 foreach loops associative arrays, 140–141 database storage, 342 loading files, 193 modifying files, 194 splitting function, 203 storing output, 199–200 versus for loops, 137 with arrays, 135–137 XML, 292–293 while loops building, 106–107 endless loops, 105–106 repeating code, 103–105 M mail() function, 203 mailMerge program, 200–203 mainButton() function, 401, 408, 427 many-to-many relationships, 367, 376–380 many-to-oone relationships, 367 master files, quiz program, 217 mathematical operators, 32–33 menu system simpleCMS, 283–285 XML, 288 methods, object, 233, 234, 248 adding to class, 253–254 access methods, 256 constructor, 254–255 getter methods, 256 setter methods, 255 minus sign (-), 32 modifying files, 194 multidimensional arrays building, 144–147 distance queries, 147–149 city names, 148 distances, 148–149 multi-line strings, 29–30 multiple ffield queries, 40 multiple values, 66–68 multiplication symbol ( * ), 32 mysql_fetch functions, 340–341 N naming class keyword, 252 files, 187 functions, 80 string variables, 25 negative results, 63 Ace or Not program, 64 else clause, 65–66 netcraft survey, 6 newline, 98 normalization. See data normalization notepad, 6 numeric variables mathetical operators, 32–33 ThreePlusFive program, 30–32 O object-oriented programming (OOP). See also superHTML object adding methods to class, 253–254 access methods, 256 building constructor, 254–255 getter method, 256 property setter, 255 creating basic object, 249–251 critter class, 251–252 properties, 252 inheritance, 249, 257–260 overview, 230, 248–249 encapsulation, 249 inheritance, 249 polymorphism, 249 one-to-one relationships, 366–367 openDir() function, 196 opening files, 187 ORDER BY clause, 327 ord() functtion, 159–160 output storage, 199–200 ownership, file, 187 434 I n d e x P pairs, counting, 126–128 parameters accepting in verse() function, 84–85 sending to functions, 80–82 param.php program, 80–82 parsers result sets, 341–342 word lists, 163, 164–165 XML, 288–289 passwords database connection, 338 PHPNuke, 276 quiz program, 213–214, 221–222 pattern segment expression operator, 198 persistence program, 114 form fields, 114–116 hidden fields, 117 text boxes, 116–117 Petals Around the Rose game, 56, 88 calcNumPetals function, 92–93 ending HTML code, 94 main body code, 89 printDice() function, 90–91 printForm() function, 93 printGreeting() function, 89–90 showDie() function, 91–92 starting HTML, 88–89 phpInfo() function, 304 phpMyAdmin intterface connecting to server, 316–317 creating tables, 317–318 editing tables, 318 exporting tables, 319–322 functions, 315–316 PHP-Nuke customizing, 277–278 installing, 276 working with, 274–276 Pig Latin translator, 154–159 pipeline (|), 199 plus sign (+), 32 pointer, directory, 196–197, 206 Pokerr Dice game, 96, 114 evaluate() function, 123–129 main code body, 118–119 printing results, 129–130 rollDice() function, 119–123 setting up HTML, 117–118 polymorphism, 249, 255 portal, Web, 274 post method, 35, 36, 178 preg_grep() function, 197, 208 preg_match() function, 419, 420 primary key, 310, 370, 377, 418, 419 printDice() function, 90–91 printForm() function, 93 print() function, 83 printGreeting() ffunction, 89–90 printing adventure game code, 354–355 answer key, 178–179 East code, 171–173 other directions, 173–174 Poker Dice program, 121–123, 129–130 puzzle, 176–178 quiz form, 214–215 variable’s value, 26 printPuzzle() function, 176–178 procAdd() function, 405 process add module, 391, 405–406, 425 properties, object, 248, 252 property program, 233–235 puzzle board adding foil letters, 175–176 making, 174–175 printing, 176–179 Q qToList() function, 408–409 qToTable() function, 400, 410 query creation, MySQL, 339–340 query form, spyMaster, 395–397, 399–401 quick lissts, 408–409 quiz editing, 182 log, 185 results, 184 taking, 183–184 quizMachine program, 182–183 building, 203–211 edit list, 208–210 getting file list, 205–206 log list, 210–211 take a test list, 206–208 editing test getting test data, 212–214 HTML file, 217–220 main logic, 216–217 master file, 217 printing form, 214–215 writing test, 215 grading quiz, 222–225 taking quiz, 220–222 viewing log, 225–226 quotation marks, 287 435 I n d e x R r+ file access modifier, 188, 191 radio groups, 46 random access modifiers, 188 random numbers creating, 56 printing corresponding image, 58–59 Roll Em program, 57–58 readdir() function, 196–197 readFile() function, 193, 200, 221 reading form elements, 43–46 reading files into arrays Cartoonifier program, 192–193 loading file, 193–194 modifying file, 194 read mode, 188 real numbbers, 32 records, database, 305 redundancy, 365 register globals, 15, 142–143 regular expressions, 197–199, 420 regular fields, librrary module, 420 relational database management system (RDBMS), 301 Adventure Generator, 300–302, 328–333 committing changes, 355–356 connections, 342–343 editing records, 350–355 segment display, 343–348 viewing records, 348–350 choosing database, 339 creating database, 305–312 creating tables, 306–311 inserting values, 311–312 selecting results, 312–313 creating queries, 322–328, 339–340 limiting columns, 324–327 UPDATE statement, 327–328 database connection, 336–339 field names, 340–341 MySQL installing, 303–304 using executable, 304–305 phpMyAdmin program, 315–322 connecting to server, 316–317 creating tables, 317–318 editing table data, 318 exporting tables, 319–322 result sets, 341–342 using, 302–303 writing scripts, 313–315 relationship types, 366–367 repetittion, character, 198 result sets, 339, 341–342 returning values, 83–84 rollDice() function, 119–123 roll Em program, 57–58 row limittation, tables, 325–327 Row Your Boat page, 28–29 rToEdit() function, 413–415 S safe mode, 15 saveRoom program, 355–356 saveSonnet program, 185–186 scalar values, 203 scope, variable, 85–87 scripts building tables, 313–315 for data retrieval, 35–36 exporting tables, 321–322 setting action attributes to, 35 spy database, 368–369 tags execution, 12–13 secoond normal form, 365 security passwords, 213–214, 221–222 SELECT command, 312–313, 323–324, 397, 409 select elements, reading, 45 select() function,, 244–245, 268 select objects, building, 268 semicolon (;) beginning extensions, 17 ending lines, 27, 62 if statements, 62, 63 inside strings, 30 sending data without forms embedding data, 38–39 get method, 36–38 multiple field queries, 40 sentry variables behavior, 100, 103 changing, 99–100 for loop, 98–99 while loop, 106–107 serverss connections, 316–317 functions, 5 names, 338 programming on, 3–4 testing, 7–8 server-side programs, 3, 4, 230 setName() function, 255, 256 setter methods, 255 setTitle() function, 261 showDie() funnction, 91–92 showEdit() function, 208–210 436 I n d e x showLog() function, 210–211 showLog program, 225–226 showSegment program, 343–348 showTest() function, 206–208 simpleCritter claass, 251 size detection, arrays, 110–111 slashes backward, 98 forward, 32 regular expression operator, 198 smartToEdit() function, 402, 413, 415–418, 419, 426 SOURCE command, 313, 314–315 span tag, 281, 282 split()) function, 157, 165, 203, 225 spy database, 360 building tables, 367–368 creating tables, 368–371 operation table, 371–373 setting up, 368–369 connecting tables, 373–376 data design, 363 data normalization, 363–366 inconsistent data, 361–362 link tables, 376–380 listed fields, 362–363 operation information, 362 relationship types, 366–367 specialty table, 377–379 spyMaster program, 384–389, 395–399 startTable() function, 241, 266 state diagram, 390–392 stateless protocol, 114 storage ooutput, 199–200 story program, 22 building, 48–51 checking form, 51–53 designing, 46–47 finishing, 53–54 straights, 129 string data (text), 26 string interpolation, 26 string variables character translation, 159–160 concatenation operator, 159 creating assigning value, 26 naming, 25 finding substrings, 158 forms, 157 Pig Latin translator, 154–159 regular expressions, 197–199 searching, 158–159 split() function, 157 This Old Man program, 113 trimming, 157 VARCHAR fields, 309 str_replace() function, 194, 216, 400 strstr() function, 158–159 strtoupper() function, 165 structured query language ((SQL), 302–303, 307 exporting tables, 321–322 substr() function, 158 substrings, 158 subtraction symbol, 32 superHTML adding text, 261–262 bottom of page, 263 creating constructor, 261 headers, 264 manipulating properties, 261 setting up file, 260 tags, 263–264 top of page, 262 superHTML object adding text and tags, 235–237 building document, 230–233 including file, 231 variables, 231–232 Web page, 232–233 creating forms, 241–248 adding text box, 243–244 drop-down menus, 244–245 elements inside table, 245–247 viewing results, 247–248 creating lists, 237–239 ad hoc, 239 basic, 238 specialized, 239 making tables, 239–241 title property, 233–235 Switch Dice program building, 69–71 switch structure, 69–71, 73 T tab-delimited file, 201 tables creating from arrays, 265–266 one row at a time, 266 database, 305 creating, 306–311 deleting, 314 inserting values, 311–312 selecting results, 312–313 using scripts, 313–315 437 I n d e x . HTML, 88–89 phpInfo() function, 304 phpMyAdmin intterface connecting to server, 316–317 creating tables, 317–318 editing tables, 318 exporting tables, 319–322 functions, 315–316 PHP- Nuke customizing,. 84–85 sending to functions, 80–82 param .php program, 80–82 parsers result sets, 341–342 word lists, 163, 164–165 XML, 288–289 passwords database connection, 338 PHPNuke, 276 quiz program, 213–214,. table values, 311–312 installation Apache, 6–10 development environment, 5–6 MySQL, 303–304 PHP , 10–11 PHP- Nuke, 276 using existing server, 4 instructions (syntax), 27 integers, 32 Internet Information