|
|
|
1 | (10) |
|
1.1 How a Web Browser Processes an HTML File |
|
|
4 | (1) |
|
|
|
5 | (1) |
|
1.3 Creating an HTML File |
|
|
5 | (1) |
|
1.4 How PHP Files Are Processed |
|
|
5 | (2) |
|
1.5 Exercise: The Erewhon Society's Home Page |
|
|
7 | (2) |
|
|
|
9 | (2) |
|
|
|
11 | (16) |
|
2.1 Structure of a PHP Script |
|
|
11 | (3) |
|
2.1.1 Blank Lines and Layout |
|
|
12 | (1) |
|
|
|
12 | (2) |
|
2.2 How a `Mixed' PHP File Is Processed |
|
|
14 | (1) |
|
2.3 PHP: Basic Components |
|
|
14 | (1) |
|
|
|
15 | (4) |
|
2.4.1 Uninitialized Variables |
|
|
16 | (1) |
|
2.4.2 Variable Names: A Warning |
|
|
16 | (1) |
|
|
|
17 | (1) |
|
|
|
17 | (2) |
|
|
|
19 | (1) |
|
|
|
19 | (3) |
|
|
|
19 | (1) |
|
|
|
20 | (2) |
|
|
|
22 | (1) |
|
|
|
22 | (2) |
|
|
|
24 | (1) |
|
2.8 Some Combinations of Quote Characters |
|
|
24 | (3) |
|
|
|
25 | (2) |
|
3 The PHP Language: Types of Statement |
|
|
27 | (26) |
|
3.1 Overview of Statements |
|
|
27 | (1) |
|
|
|
28 | (1) |
|
3.2 Assignment Statements |
|
|
28 | (7) |
|
3.2.1 Arithmetic Expressions |
|
|
28 | (2) |
|
3.2.2 Evaluating an Arithmetic Expression |
|
|
30 | (1) |
|
3.2.3 Arithmetic Functions |
|
|
31 | (1) |
|
3.2.4 Simplified Notation for Assignment |
|
|
31 | (1) |
|
|
|
32 | (1) |
|
|
|
32 | (1) |
|
3.2.7 Simplified Notation for Joining Strings |
|
|
32 | (1) |
|
3.2.8 Logical Expressions |
|
|
33 | (1) |
|
3.2.9 Evaluating Logical Expressions |
|
|
34 | (1) |
|
|
|
34 | (1) |
|
|
|
35 | (4) |
|
3.3.1 Printing Logical Values |
|
|
39 | (1) |
|
|
|
39 | (4) |
|
|
|
40 | (1) |
|
3.4.2 Augmenting an `if' Statement with `else if' and `else' Clauses |
|
|
41 | (1) |
|
3.4.3 Dealing with Variable Values in Conditional Expressions |
|
|
42 | (1) |
|
|
|
43 | (1) |
|
3.6 Loops in PHP 1: For Loops |
|
|
44 | (1) |
|
3.7 Loops in PHP 2: WHILE Loops |
|
|
45 | (2) |
|
3.8 Loops in PHP 3: Do While Loops |
|
|
47 | (1) |
|
3.9 The Include and Require Statements |
|
|
48 | (5) |
|
|
|
51 | (2) |
|
|
|
53 | (14) |
|
|
|
53 | (1) |
|
|
|
54 | (1) |
|
4.3 The PHP Foreach Statement |
|
|
55 | (2) |
|
|
|
57 | (2) |
|
|
|
59 | (3) |
|
4.5.1 Using Associative Arrays with Dates |
|
|
62 | (1) |
|
4.6 Two Dimensional Arrays |
|
|
62 | (2) |
|
4.7 The Explode and Implode Functions |
|
|
64 | (3) |
|
|
|
65 | (2) |
|
5 Some Important Functions |
|
|
67 | (16) |
|
5.1 System Functions Applied to Numbers |
|
|
67 | (1) |
|
5.1.1 Mathematical Constant |
|
|
68 | (1) |
|
5.2 Trigonometric Functions |
|
|
68 | (1) |
|
5.3 System Functions Applied to Strings |
|
|
69 | (6) |
|
|
|
69 | (1) |
|
|
|
70 | (1) |
|
5.3.3 Converting Initial Letters to Uppercase |
|
|
71 | (1) |
|
5.3.4 Replacing One Substring by Another |
|
|
71 | (1) |
|
|
|
72 | (1) |
|
5.3.6 Manipulating a Substring |
|
|
72 | (1) |
|
5.3.7 Converting a String to an Array and Vice Versa |
|
|
73 | (1) |
|
|
|
74 | (1) |
|
|
|
75 | (1) |
|
5.5 The max and min Functions |
|
|
76 | (1) |
|
|
|
77 | (2) |
|
5.6.1 List of Special One-character Arguments for the date Function |
|
|
78 | (1) |
|
|
|
79 | (1) |
|
|
|
80 | (1) |
|
|
|
80 | (1) |
|
5.10 The phpinfo Function |
|
|
81 | (2) |
|
|
|
81 | (2) |
|
6 Formatted Print Functions |
|
|
83 | (10) |
|
|
|
83 | (1) |
|
|
|
84 | (7) |
|
|
|
85 | (1) |
|
|
|
86 | (1) |
|
6.2.3 Precision Specifiers |
|
|
86 | (1) |
|
|
|
87 | (2) |
|
|
|
89 | (1) |
|
6.2.6 Outputting a Percent Sign |
|
|
89 | (1) |
|
6.2.7 Specifying Variables Explicitly |
|
|
89 | (1) |
|
|
|
90 | (1) |
|
6.2.9 List of Type Specifiers |
|
|
90 | (1) |
|
|
|
91 | (2) |
|
|
|
92 | (1) |
|
|
|
93 | (20) |
|
7.1 Directories and Sub-directories |
|
|
93 | (2) |
|
7.2 Relative Addressing Using Paths |
|
|
95 | (1) |
|
7.2.1 Relative and Absolute Addresses |
|
|
96 | (1) |
|
7.3 Storing Data in Text Files |
|
|
96 | (7) |
|
|
|
97 | (1) |
|
|
|
98 | (1) |
|
7.3.3 Writing to an Open File |
|
|
98 | (1) |
|
7.3.4 Formatted Writing to an Open File |
|
|
99 | (1) |
|
7.3.5 Reading an Open File |
|
|
100 | (1) |
|
|
|
100 | (1) |
|
|
|
101 | (1) |
|
7.3.8 Using the Explode and Implode Functions |
|
|
102 | (1) |
|
7.4 File and Directory Protections |
|
|
103 | (1) |
|
7.5 Checking Existence and Protection Status of Files and Directories |
|
|
104 | (1) |
|
7.6 Other Functions Applied to Files or Directories |
|
|
104 | (2) |
|
7.6.1 Changing File or Directory Protections |
|
|
105 | (1) |
|
7.6.2 Creating and Deleting Directories |
|
|
105 | (1) |
|
7.6.3 Renaming Files and Directories |
|
|
105 | (1) |
|
7.6.4 Getting and Changing the Current Directory |
|
|
106 | (1) |
|
7.7 Decomposing a Relative File or Directory Name into its Components |
|
|
106 | (2) |
|
|
|
108 | (1) |
|
7.8 Finding the Contents of a Directory |
|
|
108 | (1) |
|
|
|
109 | (4) |
|
|
|
111 | (2) |
|
|
|
113 | (14) |
|
|
|
113 | (4) |
|
8.2 Global and Local Variables |
|
|
117 | (1) |
|
8.3 Returning More than One Value |
|
|
118 | (1) |
|
8.4 Creating a Function Library |
|
|
119 | (2) |
|
8.5 Using a GLOBAL Statement in a Function Definition |
|
|
121 | (1) |
|
8.6 Passing an Array as a Function Argument |
|
|
121 | (1) |
|
8.7 Arguments Passed by Value and Arguments Passed by Reference |
|
|
122 | (2) |
|
8.8 Default Values for Arguments |
|
|
124 | (3) |
|
|
|
125 | (2) |
|
9 Passing Variables to a PHP Script I |
|
|
127 | (26) |
|
|
|
127 | (1) |
|
|
|
128 | (3) |
|
|
|
130 | (1) |
|
|
|
131 | (11) |
|
|
|
131 | (1) |
|
|
|
132 | (1) |
|
9.3.3 Radio Buttons in a Radio Group |
|
|
133 | (2) |
|
|
|
135 | (5) |
|
|
|
140 | (1) |
|
9.3.6 Submit and Reset Buttons |
|
|
141 | (1) |
|
|
|
142 | (6) |
|
|
|
143 | (1) |
|
|
|
144 | (1) |
|
|
|
145 | (1) |
|
9.4.4 Readonly and Disabled Fields |
|
|
146 | (2) |
|
|
|
148 | (5) |
|
|
|
151 | (2) |
|
10 Passing Variables to a PHP Script II |
|
|
153 | (22) |
|
|
|
153 | (1) |
|
|
|
153 | (13) |
|
10.2.1 Checking for Compulsory Values |
|
|
159 | (1) |
|
10.2.2 Checking for Numeric Values and Integers |
|
|
159 | (1) |
|
10.2.3 Multiple Selections |
|
|
160 | (2) |
|
|
|
162 | (2) |
|
10.2.5 Quotes in Text Fields and Textareas |
|
|
164 | (2) |
|
10.3 Passing Variables to a PHP Script as Part of a URL |
|
|
166 | (3) |
|
10.4 Passing Values to PHP Scripts Using Session Variables |
|
|
169 | (6) |
|
|
|
173 | (2) |
|
11 PHP in Action: Managing a Members' Area |
|
|
175 | (22) |
|
|
|
176 | (3) |
|
11.2 Turning PHP On and Off |
|
|
179 | (1) |
|
|
|
180 | (1) |
|
|
|
181 | (2) |
|
11.5 Storing Data in Text Files |
|
|
183 | (1) |
|
|
|
184 | (2) |
|
|
|
186 | (11) |
|
11.7.1 Generating the Access Table |
|
|
187 | (3) |
|
11.7.2 Displaying the Results in Tabular Form |
|
|
190 | (3) |
|
11.7.3 Adding HTML Tags Using Include |
|
|
193 | (2) |
|
|
|
195 | (2) |
|
12 Using a MySQL Database I |
|
|
197 | (20) |
|
|
|
197 | (2) |
|
|
|
199 | (1) |
|
12.2.1 Specifying the Current Database |
|
|
199 | (1) |
|
|
|
199 | (1) |
|
12.4 Issuing MySQL Commands |
|
|
200 | (1) |
|
12.5 Naming Databases, Tables and Fields |
|
|
201 | (1) |
|
12.5.1 Case Sensitivity of Database, Table and Field Names |
|
|
201 | (1) |
|
12.6 Setting a Primary Key |
|
|
202 | (1) |
|
12.7 Adding a Record to the mytablel Table |
|
|
202 | (4) |
|
12.7.1 The INSERT INTO Command |
|
|
204 | (2) |
|
12.7.2 The REPLACE INTO Command |
|
|
206 | (1) |
|
|
|
206 | (1) |
|
|
|
207 | (2) |
|
|
|
209 | (5) |
|
12.11 Summary of MySQL Commands |
|
|
214 | (3) |
|
|
|
215 | (2) |
|
13 Using a MySQL Database II |
|
|
217 | (26) |
|
|
|
218 | (10) |
|
|
|
219 | (3) |
|
|
|
222 | (2) |
|
13.1.3 Displaying Values that are not Fields |
|
|
224 | (1) |
|
|
|
224 | (2) |
|
13.1.5 Applying Functions to the Values of a Field |
|
|
226 | (1) |
|
13.1.6 Finding the Number of Records in a Table |
|
|
227 | (1) |
|
13.1.7 Finding All the Distinct Values of a Field |
|
|
227 | (1) |
|
13.2 Complex Select/Update Commands |
|
|
228 | (1) |
|
13.3 Combining Tables: Inner and Outer Joins |
|
|
228 | (4) |
|
13.4 Auto_Increment Fields |
|
|
232 | (2) |
|
|
|
234 | (2) |
|
|
|
234 | (1) |
|
|
|
235 | (1) |
|
13.5.3 Show Fields / Show Columns / Describe |
|
|
235 | (1) |
|
|
|
236 | (1) |
|
13.6 Some Further Commands and Adding Comments |
|
|
236 | (1) |
|
|
|
237 | (1) |
|
|
|
237 | (1) |
|
13.6.3 Deleting a Database |
|
|
237 | (1) |
|
13.6.4 Including a Comment in a MySQL Command |
|
|
237 | (1) |
|
13.7 Summary of MySQL Commands |
|
|
237 | (6) |
|
|
|
241 | (2) |
|
14 Creating and Updating MySQL Tables |
|
|
243 | (12) |
|
|
|
243 | (1) |
|
|
|
244 | (3) |
|
|
|
244 | (1) |
|
|
|
245 | (1) |
|
14.2.3 Floating Point Types |
|
|
246 | (1) |
|
|
|
246 | (1) |
|
|
|
247 | (1) |
|
14.2.6 Date and Time Types |
|
|
247 | (1) |
|
14.3 Not Null And Default Clauses |
|
|
247 | (2) |
|
14.3.1 Implied Default Values |
|
|
248 | (1) |
|
14.4 AUTO_INCREMENT Clause |
|
|
249 | (1) |
|
|
|
249 | (1) |
|
|
|
249 | (1) |
|
14.7 Changing the Structure, the Name and the Field Specifications of a Table |
|
|
250 | (2) |
|
|
|
250 | (1) |
|
14.7.2 Set the Starting Value for an AUTO_INCREMENT Field |
|
|
250 | (1) |
|
14.7.3 Change the Name of a Table |
|
|
250 | (1) |
|
|
|
250 | (1) |
|
14.7.5 Change the Name and/or Structure of a Field |
|
|
251 | (1) |
|
14.7.6 Changing a Default Value |
|
|
251 | (1) |
|
14.8 Using the SHOW Command to Find the Structure of a Table |
|
|
252 | (1) |
|
14.9 Summary of MySQL Commands |
|
|
252 | (3) |
|
|
|
253 | (2) |
|
15 Using a PHP Script to Manage a MySQL Database |
|
|
255 | (28) |
|
15.1 Connecting to a Database |
|
|
256 | (10) |
|
15.2 A PHP Function to Display the Result of a Selection |
|
|
266 | (3) |
|
15.2.1 Finding the Version of MySQL |
|
|
268 | (1) |
|
15.3 Using Simpler MySQL Commands |
|
|
269 | (1) |
|
|
|
270 | (4) |
|
15.5 A Visual MySQL Command Processing Tool |
|
|
274 | (5) |
|
15.6 The PHP mysql_affected_rows Function |
|
|
279 | (1) |
|
15.7 The PHP mysql_insert_id Function |
|
|
280 | (1) |
|
15.8 Converting mysql_Functions to mysqli_Functions |
|
|
280 | (3) |
|
|
|
282 | (1) |
|
16 PHP in Action: Converting Data between Text Files and Database Tables |
|
|
283 | (18) |
|
|
|
284 | (1) |
|
16.2 Data Cleaning for the Plays Dataset |
|
|
284 | (8) |
|
16.3 Extracting Information from a Table: Finding the Next Production |
|
|
292 | (3) |
|
16.4 Backing up and Restoring a Table |
|
|
295 | (3) |
|
|
|
297 | (1) |
|
16.5 Using the explode Function When There Are Multiple Occurrences of the Separator |
|
|
298 | (3) |
|
|
|
299 | (2) |
|
17 Using PHP to View and Edit Database Tables |
|
|
301 | (20) |
|
17.1 Analyzing the Current Database |
|
|
301 | (6) |
|
17.2 Building a Visual Table Editor |
|
|
307 | (14) |
|
17.2.1 Developing an Editing Page |
|
|
307 | (1) |
|
17.2.2 Developing the Destination Page |
|
|
308 | (8) |
|
17.2.3 Changing and Adding to a Table |
|
|
316 | (4) |
|
|
|
320 | (1) |
|
18 PHP in Action: Maintaining a Membership List |
|
|
321 | (24) |
|
|
|
321 | (7) |
|
|
|
328 | (6) |
|
18.3 Sending Email from a PHP Script |
|
|
334 | (2) |
|
18.4 Generating Passwords |
|
|
336 | (3) |
|
18.5 Managing the Members Table |
|
|
339 | (6) |
|
|
|
344 | (1) |
|
|
|
345 | (40) |
|
19.1 PHP System Functions |
|
|
345 | (11) |
|
19.1.1 Abbreviations Used in Specifications of Function Arguments |
|
|
345 | (1) |
|
19.1.2 Terms Used in Specifications of Function Arguments |
|
|
345 | (1) |
|
19.1.3 System Functions Applied to Numbers |
|
|
346 | (1) |
|
19.1.4 Trigonometrie Functions |
|
|
347 | (1) |
|
19.1.5 System Functions Applied to Arrays |
|
|
348 | (1) |
|
19.1.6 System Functions Applied to Strings |
|
|
348 | (1) |
|
19.1.7 System Functions Applied to Variables |
|
|
349 | (1) |
|
19.1.8 System Functions for Use with Arrays |
|
|
349 | (2) |
|
19.1.9 Formatted Print Functions |
|
|
351 | (1) |
|
19.1.10 System Functions for Use with Text Files |
|
|
351 | (2) |
|
19.1.11 Logical Functions |
|
|
353 | (1) |
|
19.1.12 Functions Used with Sessions (see Chap. 10 for more details) |
|
|
353 | (1) |
|
19.1.13 Functions Used with Uploaded Files (see Chap. 10 for more details) |
|
|
353 | (1) |
|
19.1.14 Other System Functions |
|
|
354 | (1) |
|
19.1.15 System Functions Used for Manipulating a MySQL Database |
|
|
354 | (2) |
|
19.1.16 `Improved' System Functions Used for Manipulating a MySQL Database (See Sect. 15.8) |
|
|
356 | (1) |
|
19.2 PHP System Operators |
|
|
356 | (2) |
|
19.2.1 Binary Arithmetic Operators Applied to Numerical Expressions |
|
|
356 | (1) |
|
19.2.2 Unary Arithmetic Operators Applied to Numbers |
|
|
357 | (1) |
|
19.2.3 System Operators Applied to Strings |
|
|
357 | (1) |
|
19.2.4 Relational Operators |
|
|
357 | (1) |
|
|
|
357 | (1) |
|
19.2.6 Operators Giving a Simplified Notation for Assignment |
|
|
358 | (1) |
|
19.2.7 Operators Giving a Simplified Notation for Joining Strings |
|
|
358 | (1) |
|
19.3 Summary of MySQL Commands |
|
|
358 | (4) |
|
19.4 MySQL Operators and Functions |
|
|
362 | (2) |
|
19.4.1 Simple Conditions in WHERE Clauses |
|
|
362 | (1) |
|
19.4.2 Complex Conditions in WHERE Clauses |
|
|
363 | (1) |
|
19.4.3 Other Functions in SELECT Commands |
|
|
363 | (1) |
|
|
|
363 | (1) |
|
19.5 Summary of Case-Sensitivity Rules: PHP and MySQL |
|
|
364 | (1) |
|
|
|
364 | (1) |
|
|
|
364 | (1) |
|
|
|
364 | (1) |
|
|
|
365 | (1) |
|
19.7 Specimen Solutions to Practical Exercises |
|
|
366 | (13) |
|
19.7.1 Practical Exercise 2 |
|
|
366 | (1) |
|
19.7.2 Practical Exercise 3 |
|
|
366 | (1) |
|
19.7.3 Practical Exercise 4 |
|
|
367 | (2) |
|
19.7.4 Practical Exercise 5 |
|
|
369 | (1) |
|
19.7.5 Practical Exercise 6 |
|
|
370 | (1) |
|
19.7.6 Practical Exercise 7 |
|
|
370 | (1) |
|
19.7.7 Practical Exercise 8 |
|
|
371 | (1) |
|
19.7.8 Practical Exercise 9 |
|
|
372 | (1) |
|
19.7.9 Practical Exercise 10 |
|
|
373 | (1) |
|
19.7.10 Practical Exercise 11 |
|
|
373 | (1) |
|
19.7.11 Practical Exercise 12 |
|
|
374 | (1) |
|
19.7.12 Practical Exercise 13 |
|
|
374 | (1) |
|
19.7.13 Practical Exercise 14 |
|
|
375 | (1) |
|
19.7.14 Practical Exercise 15 |
|
|
376 | (1) |
|
19.7.15 Practical Exercise 16 |
|
|
377 | (1) |
|
19.7.16 Practical Exercise 17 |
|
|
378 | (1) |
|
19.7.17 Practical Exercise 18 |
|
|
378 | (1) |
|
|
|
379 | (6) |
| Index |
|
385 | |