Matthew M.

Matthew M.

Web Application Development

Slide Duration:

Table of Contents

Section 1: Advanced PHP with MySQL
Course Introduction

13m 36s

Intro
0:00
Advanced PHP w/ MySQL
0:13
Course Introduction
0:14
Course Content
0:59
Web Application: Educator Store
1:45
Web Application: Educator Store
1:46
Object-Oriented Programming
6:09
Object-Oriented Programming Overview
6:10
MySQL
6:50
MySQL Overview
6:51
Example: Command Prompt & MySQL
8:34
What You Will Learn
9:34
What You Will Learn
9:35
Course Prerequisites
11:52
Course Prerequisites
11:53
Advanced Course Development Environment

18m 46s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Development Environment Setup
1:36
Firefox Web Browser, XAMPP, and PSPad Text Editor
1:37
Course Directory Structure
4:36
Course Directory Structure
4:37
phpDocumentor
7:23
phpDocumentor Overview
7:24
Parsing Source Code
7:44
docs Subdirectory
9:06
Asvanced PHP Course Documentation Example
10:21
Previous Educator PHP Students
14:14
Lib Directory Changes
14:38
Images Directory Changes
14:57
VERSION Constant
15:40
Comments Noting a Specific Version Number
17:04
Homework Challenge
17:30
Homework Challenge
17:31
Introduction to File I/O

35m 37s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
File I/O
1:34
File I/O Overview
1:35
Performing file I/O: 3 Steps
1:52
File Permissions
2:28
Read Permission & Write Permission
2:29
fopen()
4:47
fopen()
4:48
Two Required Parameters
5:01
Successful fopen(): File Handle and Resource
5:21
FALSE and E_WARNING Error
6:00
Example
6:39
File Paths
7:10
File Paths
7:11
File Access Modes
9:18
File Access Modes
9:19
Coding Example: fopen()
10:31
Using Relative and Absolute Path & Non-Existent File
10:32
File Pointers
15:55
File Pointers
15:56
Example File
16:11
Opening a File with fopen() Using 'r' as the Access Mode
16:22
fgets()
17:55
fgets() Overview
17:56
Coding Example: fgets() - Reading a Line at a Time
18:26
feof()
20:10
feof() Overview
20:09
Coding Example: feof()
20:50
fclose()
23:43
fclose() Overview
23:44
Coding Example: fclose()
25:02
Coding Example: Current Stock
26:10
Coding Example: Current Stock
26:11
trim ()
31:39
trim () Overview and Example
31:40
Homework Challenge
33:35
Homework Challenge
33:36
Web Application Development

36m 36s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
Version 1.0 Changelog
0:31
catalog.php
0:32
Function Library: fileLIB.php
5:00
Version 1.1 Changelog
27:12
createItemDataArray() and createDeptDataArray()
27:13
outputSimpleItemLink() and outputSimpleDeptLink()
32:06
HTTP & the POST Method

34m 36s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
HTTP Model
1:28
HTTP Model
1:29
Client-Server Model 2 Steps Process
2:00
HTTP Messages
2:23
HTTP Messages
2:24
HTTP Requests
3:09
HTTP Requests
3:10
Example: HTTP Request Header
3:17
Coding Example: HTTP Requests
4:29
HTTP Responses
7:15
HTTP Responses
7:16
Example: HTTP Response (Header & Body)
8:00
header()
11:47
header() Overview
11:48
Coding Example: header
14:02
Coding Example: header() Error
14:52
GET Method
18:55
GET Method
18:56
Coding Example: GET Method
20:13
POST Method
21:09
POST Method
21:10
Coding Example: Sample Form Using the POST Method
23:50
Accessing POST Data in PHP
26:38
Accessing POST Data in PHP
26:39
Coding Example: Accessing POST Data via $_POST
28:15
GET vs. POST
29:54
GET vs. POST
29:55
Example: Accessing POST Data via $_POST
31:20
Example: Accessing POST Data via $_POST
31:21
Homework Challenge
33:00
Homework Challenge
33:01
Web Application Development

14m 11s

Intro
0:00
Version 2.0 Changelog
0:09
Updating the Site's Current Form to Use the POST Method
0:10
Creating Admin Website
2:55
Dynamically Generated Department List
12:40
Writing to Files

17m 38s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Review of File I/O
0:40
Review of File I/O
0:41
fwrite()
1:38
fwrite()
1:39
fputs()
2:20
'r+'
2:31
Coding Example: fwrite()
2:59
fopen() Access Modes
8:41
'a' and 'a+'
8:42
'w' and 'w+'
11:34
Homework Challenge
14:47
Homework Challenge
14:48
Web Application Development

28m 14s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
Updated Open File Functions
0:19
openItemsDataFile ( ), openDeptsDataFile ( ), and openLastAddedFile ( )
0:20
insertItem()
6:25
insertItem() Overview
6:26
Functions: createItemDataString ( ) and updateLastItemAdded ( )
7:07
addItemToDepartment ()
16:03
addItemToDepartment () Overview
16:04
Functions: createDeptDataString ( ) and updateDepartment ( )
17:55
HTTP POST: File Uploads

22m 51s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
POST Data Encoding
1:13
POST Data Encoding
1:14
When Data is Included in the Body of the HTTP POST Request and is of the Content Type
1:31
When Uploading Files Using HTTP POST
3:17
Uploading Files
6:22
Uploading Files
6:23
If Encoding Type is Not Set to Multipart/Formdata
9:27
$_FILES Superglobal
10:59
$_FILES Superglobal
11:00
Structure of $_FILES
12:15
Structure of $_FILES: Name, Type, tmp_name, Error, and Size
12:16
Coding Example: $_FILES Superglobal
13:34
Moving an Uploaded File
15:39
Introduction to Moving an Uploaded File
15:40
move_uploaded_file ( ): Definition and Example
16:40
Homework Challenge
21:19
Homework Challenge
21:20
Web Application Development

15m 30s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Uploading Item Image File
1:22
Uploading Item Image File
1:23
Uploading Item Image File (cont.)
2:43
Altering insertItem ( )
2:44
Helpfer Functions: getFileExtension ( ) and moveUploadedFile ( )
4:30
isValidItem ( )
13:03
Introduction to Object-Oriented Programming

32m 44s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Object-Oriented Programming
0:56
Introduction to Object-Oriented Programming
0:57
Associative Arrays
5:27
Associative Arrays
5:28
Classes
7:27
Classes Overview
7:28
Defining Classes
8:24
Defining Classes
8:25
Declaring Class Properties
9:25
Coding Example: Classes
10:11
Objects
12:18
Objects Overview
12:19
Classes vs. Objects
12:49
Classes vs. Objects
12:50
Instantiating Classes
14:58
Instantiating Classes
14:59
Coding Example: Instantiate an Item Object
16:30
Object Properties
19:21
Access and Set an Object's Property
19:22
Coding Example: Set & Access the Properties of an Item Object
24:23
Homework Challenge
30:22
Homework Challenge
30:23
Web Application Development

17m 47s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 5.0 Overview
0:50
Version 5.0 Overview and Examples
0:51
Outputting Object Properties
12:38
Outputting Object Properties
12:39
Array Object Properties
14:18
Access and Set Array Value
14:19
Object Methods

39m 57s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Object Methods
0:52
Definition of Object Methods
0:53
Calling Object Methods
3:25
Calling Object Methods
3:26
Coding Example: Simple Object Methods
4:44
Object Methods and Return Values
7:02
$this Variable
10:06
$this Variable: Definition and Example
10:07
$this Variable (cont.)
15:51
$this Variable (cont.)
15:52
Getters & Setters
21:21
Getters & Setters Methods
21:22
Object Methods In Strings
25:46
Object Methods In Strings
25:47
Coding Example: Outputting Method Return Values in Strings
27:41
Using $this to Call Other Methods
28:49
Using $this to Call Other Methods
28:50
Homework Challenge
34:18
Homework Challenge: 1-3
34:19
Homework Challenge (cont.)
36:20
Homework Challenge: 4-6
36:21
Homework Challenge (cont.)
37:52
Homework Challenge: 7-10
37:53
Web Application Development

17m 30s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 6.0 Overview
0:40
Version 6.0 Changes & Examples
0:41
Item Methods
0:53
Item Class Definition: getImageFilename()
0:54
Coding Example: getImageFilename()
1:58
Department Methods
7:33
addItem(), removeItem(), and isItemInDept() Method
7:34
addItemtToDepartment() & buildDeptObject() Functions
11:46
A Default Value Needed to Be Set for $items
16:26
Object Constructors

22m 20s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Object Constructors
0:32
Introduction to Object Constructors
0:33
Coding Example: Object Constructors
1:43
Defining Constructors
3:26
Defining Constructors
3:27
Coding Example: Constructors with No Arguments
4:24
Constructor Arguments
8:09
Constructor Arguments
8:10
Coding Example: Constructor Arguments
9:49
Important Notes
16:13
Important Notes
16:14
Homework Challenge
17:35
Homework Challenge: 1 - 4
17:36
Homework Challenge (cont.)
19:13
Homework Challenge: 5 - 9
19:14
Homework Challenge (cont.)
21:40
Homework Challenge: 10 and 11
21:41
Web Application Development

16m 19s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 7.0 Overview
0:39
Version 7.0 Overview
0:40
Item Constructor
2:19
Item Constructor
2:20
Department Constructor
7:47
Department Constructor
7:48
Customer Constructor
12:23
Customer Constructor
12:24
More Magic Methods

53m 37s

Intro
0:00
Lesson Overview
0:13
Lesson Overview
0:14
Magic Methods
1:12
Magic Methods
1:13
Destructors
2:45
Destructors Overview
2:46
Coding Example: Calling Destructors
4:30
Coding Example: Object Destructor
9:19
_to String ()
16:12
_to String () Overview
16:13
Coding Example: _to String () Magic Method
18:10
Access Modifiers
21:23
Introduction to Access Modifiers
21:24
Access Modifiers: Public
21:39
Access Modifiers: Private
22:18
Access Modifiers: Protected
22:41
Object Properties and Methods
23:06
Coding Example: Public Access Modifiers
26:48
Coding Example: Private Access Modifiers
28:30
_get()
31:37
_get() Overview
31:38
Coding Example: _get () Magic Method
33:30
_set ()
36:23
_set () & the Magic Method
36:24
Using Getters & Setters
44:37
Coding Example: Using Getters & Setters
44:38
Homework Challenge
50:33
Homework Challenge: 1 - 6
50:34
Homework Challenge (cont.)
51:41
Homework Challenge: 7 - 12
51:42
Web Application Development

31m 12s

Intro
0:00
Version 8.0 Review
0:12
Version 8.0 Review
0:13
private Object Properties
1:15
private Object Properties
1:16
Coding Example
2:54
_toString() Methods
6:51
_toString() Methods
6:52
Coding Example
8:09
DataFile Class
13:27
DataFile Class & I/O Operations
13:28
Using DataFile Class: Instantiate a DataFile, DataFile open () Method, and DataFile close () Method
18:09
Homework Challenge
29:35
Homework Challenge
29:36
Classes vs. Objects

37m 49s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Class vs. Object Review
0:58
Class vs. Object Review
0:59
Static Properties
2:42
Static Properties
2:43
Scope Resolution Operator (::)
5:26
Scope Resolution Operator (::) & Static Property
5:27
Coding Example: Accessing a Static Property Using the Scope Resolution Operator
7:57
Coding Example: Accessing a Static Property in a Class Definition
10:33
Coding Example: Using a Static Property as an Instance Counter
14:18
Static Methods
18:51
Static Methods Overview
18:52
Coding Example: Static Methods
21:39
Classes vs. Objects
26:28
Classes vs. Objects: Diagrams
26:29
Class Constants
30:24
Class Constants Definition
30:25
Coding Example: Using Class Constants
31:55
Homework Challenge
34:01
Homework Challenge: 1 - 5
34:02
Homework Challenge (cont.)
35:25
Homework Challenge: 6 - 10
35:26
Web Application Development

21m 7s

Intro
0:00
Version 9.0 Overview
0:12
Version 9.0 Changes & Examples
0:13
Output Class
1:08
Output Class & Static Methods
1:09
outputHtmlSelector ( ) Method
2:43
outputItemSelector ( ) Method
4:53
outputDeptSelector ( ) Method
6:42
buildObject() Methods
11:54
buildObject() Methods & Examples
11:55
Exceptions

22m 43s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
try Blocks
0:44
try Blocks Definition
0:45
catch Blocks
2:03
catch Blocks: Definition and Syntax
2:04
Coding Example: try/catch Blocks
3:48
When an Exception Object is Caught & Error Handling
5:59
Exception Class
7:02
Exception Class
7:03
Coding Example: Using try/catch to Catch an Exception Thrown from a Method
8:04
Re-Throwing Exceptions
16:39
Re-Throwing Exceptions
16:40
Coding Example: Re-throwing an Exception
17:21
Homework Challenge
20:40
Homework Challenge: 1 - 5
20:41
Homework Challenge (cont.)
22:17
Homework Challenge: 6
22:18
Web Application Development

22m

Intro
0:00
Version 10.0 Overview
0:11
Updating addItem.php, addItemToDept.php, and error.php
0:12
Updating DataFile Class: open ( ) Method & try/catch blocks
7:45
Version 10.1 Overview
13:37
Version 10.1 Changes & Examples
13:38
Updating DataFile Class: close ( ) Method & logWarning ( )
20:17
Cookies

39m 47s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
What is a Cookie?
1:15
Definition of Cookie
1:16
HTTP - A Stateless Protocol
2:17
HTTP - A Stateless Protocol
2:18
Purpose of Cookies
4:10
Set - Cookie Header
6:21
Introduction to Set - Cookie Header
6:22
Coding Example: Set - Cookie Header
7:38
Cookie Header
9:45
Introduction to Cookie Header
9:46
Example: Cookie Header
10:27
setcookie()
12:33
Introduction to setcookie()
12:34
Example: Using setcookie
13:54
Cookies Attributes
15:48
Cookies Attributes Overview
15:49
Common Cookies Attributes: Domain
16:24
Common Cookies Attributes: Path
17:04
Common Cookies Attributes: Expires
19:34
Coding Example: Setting Cookie Attributes
20:58
$_COOKIE Superglobal
27:03
$_COOKIE Superglobal
27:04
Coding Example: Accessing Cookies from PHP Using $_COOKIE
29:45
Security Implications
34:44
Security Implications
34:45
Homework Challenge
36:10
Homework Challenge: 1 - 4
36:11
Homework Challenge (cont.)
37:47
Homework Challenge: 5 - 7
37:48
Web Application Development

39m 11s

Intro
0:00
Lesson Overview
0:17
Lesson Overview
0:18
instanceof Operator
1:34
instanceof Operator
1:35
Objects with Object Properties
2:53
Objects with Object Properties
2:54
Version 11.0 Overview
6:41
Version 11.0 Changes: Cart and CartItem Classes
6:42
Version 11.0 Coding Example
10:40
Version 11.1 Overview
31:03
Version 11.1 Changes & Examples
31:04
Introduction to Sessions

46m 8s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
What is a Session?
0:53
What is a Session?
0:54
Client-Side Sessions
3:51
Client-Side Sessions
3:52
Server-Side Sessions
5:04
Server-Side Sessions
5:05
Session IDs
6:26
Session IDs
6:27
The SID is Used by the Server to:
7:08
A Client Passes an SID to the Server with Each HTTP Request Via:
8:15
Sessions in PHP
12:19
Sessions in PHP
12:20
session_start()
14:40
session_start() Overview
14:41
Coding Example: Using session_start () to Continue a Session
18:03
$_SESSION Superglobal
22:06
$_SESSION Superglobal Overview
22:07
Coding Example: Setting a Session Variable via $_SESSION
25:22
Accessing Session Data
28:08
Accessing Session Data
28:09
Deleting Session Data
31:43
Deleting Session Data
31:44
Coding Example: Deleting Session Data
32:16
Configuring PHP Sessions
36:14
session.cookie_lifetime, session.cookie_domain, and session.cookie_path
36:15
Coding Example: Configuring PHP Sessions
37:28
Configuring PHP Sessions (cont.)
40:56
session.use_cookies, session.use_trans_sid, and session.use_only_cookies
40:57
Coding Example: Configuring PHP Sessions
42:25
Homework Challenge
42:55
Homework Challenge: 1 - 5
42:56
Homework Challenge (cont.)
44:10
Homework Challenge: 6 - 10
44:11
Homework Challenge (cont.)
45:27
Homework Challenge: 11 - 13
45:28
Web Application Development

11m

Intro
0:00
Version 12.0 Overview
0:12
Version 12.0 Changes Part I: Updating 'viewCart.php' & 'checkout.php'
0:13
Version 12.0 Changes Part II
5:03
Destroying Sessions

29m 59s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Destroying Sessions
1:02
Destroying Sessions
1:03
session_destroy()
2:10
session_destroy() Overview
2:11
Coding Example: Setting a Session Variable and Destroying a Session
3:18
Deleting Session Cookies
8:38
Deleting Session Cookies
8:39
Coding example: Deleting Session Cookies
9:17
Review of Steps
21:07
Review of Steps
21:08
Garbage Collection
21:50
Garbage Collection Overview
21:51
Coding Example: Garbage Collection
24:30
Homework Challenge
26:28
Homework Challenge: 1 - 4
26:29
Homework Challenge (cont.)
28:16
Homework Challenge: 5 - 9
28:17
Web Application Development

19m 14s

Intro
0:00
Lesson Overview
0:13
Lesson Overview
0:14
_autoload()
0:46
Introduction to _autoload ()
0:47
Version 13.0 Overview
4:06
_autoload () and SessionManager Class
4:07
Updating 'viewCart.php' & 'checkout.php'
11:16
Introduction to Databases

21m 24s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
Flat Files
1:09
Flat Files: Definition and Example
1:10
Problems Associated with Using Flat Files as a Database
2:15
Relational Databases
3:29
Relational Databases
3:30
Relational Database Management System (RDBMS)
3:50
Tables
7:43
Tables
7:44
Columns
9:24
Columns
9:25
What is SQL?
10:45
Introduction to Structured Query Language
10:46
Standard Data Types of SQL
12:23
Primary Keys
13:19
Primary Keys
13:20
Primary Key Examples
16:36
Primary Key Examples
16:37
Introduction to MySQL

28m 11s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
What is MySQL?
1:33
MySQL
1:34
MySQL Monitor
5:16
MySQL Monitor Overview
5:17
XAMPP & MySQL
5:58
In the MySQL Command: hostname, username and -p
7:05
Connecting to a MySQl Server
9:52
Connecting to a MySQl Server
9:53
Using MySQl Monitor
13:48
Using MySQl Monitor
13:49
GRANT Command
15:10
GRANT SQL Command
15:11
Privileges & Objects
18:18
Username, Hostname, and Password
19:37
Specifying Objects
20:05
Creating a PHP User Account
21:41
Creating a PHP User Account Overview
21:42
Meaning of all & *.*
23:35
Example: Creating a PHP User Account
23:48
Required Homework
26:27
Required Homework: 1 - 5
26:28
Required Homework (cont.)
27:28
Required Homework: 6
27:29
Creating Databases & Tables

23m 1s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
Creating a Database
1:40
Introduction to Creating a Database
1:41
Example: Creating a Database
3:33
CREATE TABLE Command
6:43
CREATE TABLE Command
6:44
Data Types
7:39
Numeric Data Types: INT, INT UNSIGNED, and DECIMAL
7:40
String Data Types: CHAR (M), VARCHAR (M), and TEXT
9:23
Colum Attributes
11:00
PRIMARY KEY Attribute
11:01
AUTO INCREMENT Attribute
11:35
Items Table
13:07
Items Table
13:08
Useful Commands
17:04
SHOW TABLES Command & DESCRIBE Utility Statement
17:05
Example: Creating an Items Table
17:58
Required Homework
20:51
Required Homework: 1 - 6
20:52
Required Homework (cont.)
21:55
Required Homework: 7 - 9
21:56
SQL Command: INSERT

27m 11s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
INSERT Command
1:20
SQL INSERT Command
1:21
Specifying Values
3:16
Columns with Numeric Data Types
3:17
Columns with String Data Types
3:34
Columns with AUTO INCREMENT
4:07
Inserting Items
5:21
Inserting Items
5:22
Example: Inserting Items
7:03
SQL Text Files
14:04
SQL Monitor Client
14:05
MySQL Monitor & the < Operator
15:15
Example
17:35
Required Homework
22:32
Required Homework: 1 - 6
22:33
Required Homework (cont.)
24:19
Required Homework: 7 - 10
24:20
SQL Command: SELECT

24m 57s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
SELECT Command
0:42
SELECT Command: Definition and Syntax
0:43
Results of a SELECT Query
1:53
To Specify the Retrieval of All Columns from a Table
3:06
Example: SELECT Command
4:18
WHERE Clause
7:11
WHERE Clause
7:12
A SELECT Query with WHERE Clause has the Following Syntax
8:10
A Where Condition can Contain both Logical and Comparison Operators
9:44
Literal Values
13:24
Literal Values
13:25
Example: Literal Values
14:18
ORDER BY Clause
15:31
ORDER BY Clause & SELECT Query
15:32
Ascending and Descending Order
17:30
An ORDER BY Clause can Specify Multiple Columns to Order the Rows by
18:01
Example: SELECT Query with WHERE and ORDER BY Clause
20:32
Homework Challenge
21:59
Homework Challenge
22:00
Homework Challenge (cont.)
23:54
Homework Challenge
23:55
Using PHP from MySQL

32m 43s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
PHP/MySQL Architecture
0:56
PHP/MySQL Architecture
0:57
MySQLi Extension
3:05
MySQLi Extension
3:06
Steps to Using MySQL from PHP
5:53
Four Steps to Using MySQL from PHP
5:54
Step # 3
7:18
Connecting to a Database
8:12
To Connect to a MySQL Database
8:13
To Test for Connection Errors
10:20
Running an SQL Statement
11:54
Running an SQL Statement
11:55
Example
13:30
Processing the Results
15:58
For non-SELECT Queries
15:59
MySQLi Object Property: affected_rows
16:19
For INSERT Statements on Tables with an AUTO_INCREMENT Column
18:07
Closing the Connection
19:45
Closing the Connection
19:46
Coding Example
21:24
Coding Example: Using MySQL from PHP
21:25
Homework Challenge
29:00
Homework Challenge: 1 - 4
29:01
Homework Challenge (cont.)
31:10
Homework Challenge: 5 - 9
31:11
Web Application Development

30m 30s

Intro
0:00
Lesson Overview
0:14
Lesson Overview
0:15
sprintf()
1:28
sprintf() Overview
1:29
Example
1:56
INSERT Statements with sprintf()
5:15
INSERT Statements with sprintf()
5:16
Version 14.0 Overview
10:00
Version 14.0 Changes & Examples Part 1
10:01
Version 14.0 Changes & Examples Part 2
21:58
SELECT QUERIES from PHP

24m 22s

Intro
0:00
Lesson Overview
0:14
Lesson Overview
0:15
SELECT Queries
1:21
SELECT Queries
1:22
MySQLi_Result Class
3:17
MySQLi_Result Class: num_rows
3:18
MySQLi_Result Class: fetch_assoc ( ) and fetch_object ( )
3:59
fetch_assoc()
5:17
fetch_assoc() Overview
5:18
Coding Example: Using fetch_assoc()
9:00
stdClass Objects
12:46
stdClass Objects
12:47
fetch_object()
14:19
fetch_object() Overview
14:20
Coding Example: Using fetch_object()
16:45
Freeing Result Set Memory
18:42
Freeing Result Set Memory
18:43
Coding Example: Using free ( )
20:01
Homework Challenge
22:07
Homework Challenge: 1 - 5
22:08
Web Application Development

17m 6s

Intro
0:00
Version 15.0 Overview
0:13
Version 15.0 Changes & Examples Part 1
0:14
Version 15.0 Changes & Examples Part 2
8:43
Linking Tables

24m 32s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
A Departments Table
1:08
Departments Table
1:09
How Could We Model This in a Table: Option 1
1:26
How Could We Model This in a Table: Option 2
3:12
Database Normalization
4:37
Database Normalization
4:38
Foreign Keys
8:47
Foreign Keys
8:48
Linking Table
11:26
Linking Table
11:27
Multiple Column Primary Keys
15:30
Multiple Column Primary Keys
15:31
Example
18:51
Required Homework
22:34
Required Homework: 1 - 3
22:35
Required Homework (cont.)
24:10
Required Homework: 4
24:11
Web Application Development

24m

Intro
0:00
Version 16.0 Overview
0:11
Version 16.0 Changes
0:12
Version 16.0 Coding Examples
4:12
Version 16.0 (cont.)
18:30
Version 16.0 Changes & Examples Part 2
18:31
SQL Command: DELETE

10m 33s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
DELETE Statement
0:30
DELETE Statement & Its WHERE Clause
0:31
Delete All Rows From a Table
2:57
Using DELETE from PHP
4:04
Using DELETE from PHP Overview
4:05
Coding Example: Using DELETE from PHP
6:37
Homework Challenge
8:53
Homework Challenge: 1 - 4
8:54
Web Application Development

16m 2s

Intro
0:00
Version 17.0 Overview
0:11
Version 17.0 Changes
0:12
Version 17.0 Coding Example
2:51
Transactions
12:50
Database Transaction
12:51
Steps in Using Transactions
14:00
SQL Command: UPDATE

32m 14s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
UPDATE Statement
0:54
UPDATE Statement & Its WHERE Clause
0:55
Example: UPDATE Statement
3:32
Using UPDATE from PHP
5:21
Using UPDATE from PHP Overview
5:22
Coding Example: Using UPDATE from PHP
6:53
htmlspecialchars()
9:04
htmlspecialchars()
9:05
Encoding Special Characters
9:23
Coding Example: htmlspecialchars()
13:41
addslashes()
20:40
addslashes()
20:41
Coding Example: addslashes()
22:52
Homework Challenge
27:55
Homework Challenge: 1 - 2
27:56
Homework Challenge (cont.)
30:14
Homework Challenge: 3 - 5
30:15
Homework Challenge (cont.)
30:41
Homework Challenge: 6 - 9
30:42
Web Application Development

12m 33s

Intro
0:00
Version 18.0 Overview
0:12
Version 18.0 Changes
0:13
Version 18.0 Coding Example
1:24
SQL: Joins

42m 16s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
DATETIME Data Type
1:52
DATETIME Data Type
1:53
Modeling Orders
5:12
Modeling Orders
5:13
Customers Table
10:46
Customers Table
10:47
Example
16:18
Example: Order Table in MySQL
16:19
Joins
22:26
Joins Overview
22:27
Inner Join
23:09
Example: Joins
24:11
Join Conditions
28:14
Join Conditions
28:15
Example
28:32
Join Queries
30:00
Example: Join Conditions in MySQL
30:36
Implicit Joins
34:42
Implicit Joins
34:43
Example: Implicit Joins
35:57
Aliases
37:28
Introduction to Aliases
37:29
Example: Aliases
38:55
Required Homework
40:32
Problem 1
40:33
Problem 2
41:01
Problem 3
41:17
Web Application Development

29m 34s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Inserting Orders
0:44
Inserting Orders
0:45
Version 19.0 Overview
3:45
Version 19.0 Changes & Example Part 1
3:46
Version 19.0 Changes & Example Part 2
13:18
Version 19.1 Overview
21:10
Version 19.1 Changes
21:11
Version 19.1 Coding Example
22:18
User Authentication

26m 13s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
User Authentication
1:31
User Authentication
1:32
Authentication with Sessions
2:34
Authentication with Sessions
2:35
Four Steps in Authentication via Sessions
2:50
Using Sessions to Restrict Access
3:58
Using Sessions to Restrict Access
3:59
Coding Example: Restricted Access Area
4:47
Authentication Methods
5:54
Authentication Methods Overview
5:55
Coding Example: Authentication Methods
7:31
Logging Out
9:57
Logging Out
9:58
Coding Example: Log Out
10:47
Users Table
13:50
Users Table
13:51
Example: Creating a Users Table
15:08
Password Hashing
17:30
Password Hashing
17:31
PHP and MySQL Built-in Hash Functions: sha1 ( ) and md5 ( )
18:43
Coding Example: Password Hashing
19:27
Required Homework
24:41
Required Homework: 1 - 4
24:42
Web Application Development

14m 36s

Intro
0:00
Version 20.0 Overview
0:13
Version 20.0 Changes & Examples Part 1
0:14
Version 20.0 Changes & Examples Part 2
5:05
Version 20.0 Changes & Examples Part 3
7:29
Version 20.0 (cont.)
8:31
Version 20.0 Changes & Examples Part 4
8:32
Loading...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Advanced PHP
Bookmark & Share Embed

Share this knowledge with your friends!

Copy & Paste this embed code into your website’s HTML

Please ensure that your website editor is in text mode when you paste the code.
(In Wordpress, the mode button is on the top right corner.)
  ×
  • - Allow users to view the embedded video in full-size.
Since this lesson is not free, only the preview will appear on your website.
  • Discussion

  • Download Lecture Slides

  • Table of Contents

  • Transcription

  • Related Services

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Sign up for Educator.com

Membership Overview

  • Unlimited access to our entire library of courses.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lesson files for programming and software training practice.
  • Track your course viewing progress.
  • Download lecture slides for taking notes.
  • Learn at your own pace... anytime, anywhere!

Web Application Development

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Lesson Overview 0:12
    • Lesson Overview
  • Inserting Orders 0:44
    • Inserting Orders
  • Version 19.0 Overview 3:45
    • Version 19.0 Changes & Example Part 1
    • Version 19.0 Changes & Example Part 2
  • Version 19.1 Overview 21:10
    • Version 19.1 Changes
    • Version 19.1 Coding Example

Transcription: Web Application Development

Hello again, and welcome back to Educator.com's Advanced PHP with MySQL course.0000

In today's lesson, we are going to be continuing development of our web application,0005

incorporating what we learned in our last lesson about JOINS.0008

We are going to go through two different versions of the web application in this lesson.0014

We are going to have a version 19.0 and a 19.1, which are going to do a couple of different things.0017

Before we get into those, we are going to cover the topic of inserting orders in our database,0023

because as we learned in our last lesson, and having done the required homework to set up your database to be able to handle orders,0029

we have information on orders spread over multiple tables: Orders, the Customers table, and orders_items table.0037

Because, when we create an order, we have information for that order stored in multiple tables,0047

we have to have multiple INSERT statements in order to do that.0051

For example, when we create an order, a user submits all the information about all the items in their cart, and the quantities.0057

And then, they submit customer information; and then, in our Orders table, we store a date/time stamp, and so forth.0064

Well, the first INSERT we are going to do is an INSERT into the Customers table.0072

What we are going to be doing is creating a DatabaseAccess from another method called insertOrder,0081

which is going to perform the all the INSERTs that are needed to update all of the tables for a particular order.0086

The first one it is going to do is INSERT Customers: the reason for that is that it needs to be able to generate a custID0095

for a particular customer, because then, when we go ahead and...the second INSERT we are going to do is into the Orders table0101

(and that is because our Orders table is structured: orderID, dateTimeOrdered, taxRate, and then custID);0111

so, in order to input all of this information, we need to have an INSERT0127

into the Customers table first, to figure out the ID of a particular customer.0132

Then, we are going to insert information about the order, which is going to include the date/time stamp,0137

which we are going to generate using the PHP date function.0140

Tax rate is something that is going to be set--that is going to be a static value.0144

And then, once we have done that, then we need to add all of the items associated with the order into the orders_items table.0149

So then, we are going to perform one or more INSERTs into the orders_items linking table,0155

which, again, links an orderID with an itemID, and then has columns for the quantity of that item in that order,0165

and the price of that item at the time the order was made.0175

We are going to have one INSERT statement for the Customers table.0182

We are going to have one INSERT statement for our Orders table.0185

And then, we are going to have one to many INSERTs into the orders_items table, depending on how many items.0189

And there will be an INSERT here for each item in the order.0198

So, if there were three items in the order, we would have three INSERTs into our orders_items linking table.0201

And so, that is the process that is going to be involved for ordering an item.0214

As mentioned, in version 19.0, we are going to be adding a method called insertOrder into our DatabaseAccess class.0228

And what that is going to do is replace, in checkout.php...whereas before, we were calling an emailOrder function0236

to email the order's information to the store administrator, now we are going to be storing it in the database.0244

So, we are going to replace that call to emailOrder with a call to this insertOrder function.0248

And if we take a quick look at just the function prototype for the insertOrder function0258

(actually, it's better to look at it here), we can see that, for insertOrder, we are passing it three different variables.0269

We are going to pass it a cart variable, which is our shopping cart.0277

And that is going to be the status of the user's shopping cart when they are ready to check out.0280

So, it is going to contain an array of all of the CartItem objects, which contain the quantity of each item, and then information about each item.0286

We are going to pass it a Customer object, which is something that, in checkout.php, we have already been building up0295

from the information the user submitted on the checkout.php form.0302

And then, we are also going to be passing it the tax rate, which would be...0305

we are just going to be passing it the constant sales tax rate that we have set up.0309

But that may change over time; maybe we change our configuration file to (right now it's at 10%) change the tax rate to 9%.0313

Well, that way, when we call this method, we can set the tax rate.0321

So, when we insert an order into the database, not only is it going to have the customer data;0324

it is going to have information about all the items and their prices at the current time;0328

but it is also going to have the tax rate that was used at the time of that order.0331

And so, that way, we can recalculate that total down the road, when we want to look up orders in the database.0336

And what it is going to do is: this insertOrder method is going to build up an Order object,0341

which is just like a Customer object, or our Item, or our Department object.0347

It is an object that represents the data of an order.0351

So, if we take a look at the Order class, we can see that it has a couple of properties.0355

It has an orderID property, which is the unique primary key ID of a particular order.0364

It is going to have a string that is going to represent the date and timestamp that an order was made.0370

It is going to have a float field, which is going to be the tax rate associated with the order.0375

It is going to have a custID string, which is going to be that foreign key that is going to link an order to a customer in the Customers table.0382

And then, it is also going to have an indexed array of what we are going to call OrderItem objects.0391

And what that is: there is going to be one OrderItem object created in this array property of the Order class for each item that is in the cart.0397

What an OrderItem is: it is kind of like the CartItem object that we had been using before.0410

An OrderItem represents a row in the orders_items table; so it has the orderID that this OrderItem object is referring to;0418

it has the itemID that it is referring to; so between those two, it is going to say, "This is the item, and this is the particular order that it is in."0432

And then, in our orders_items table, we also have a price and quantity associated with the item in that order.0440

So, that is going to have fields: a float field for price, and then an integer field for quantity.0444

So, that is going to represent all of those rows in our Items table.0449

That Order object is going to contain all of the information in the Orders table as fields.0454

It is going to contain the custID, which is going to be the ID of the customer that made the order.0459

And then, it is going to contain an array of all the different order items.0468

What we are going to do in our insertOrder method is build up this object.0470

After we have inserted the order information into these three different tables, we return that Order object,0475

assuming there is no error, in which case we would return false.0481

If we go and look at our insertOrder method, we can see what we had learned about on the last page:0486

that inserting an order into the database is going to involve multiple INSERT statements.0497

We can see that it takes a shopping Cart object, a Customer object, and a tax rate.0504

And the first thing it does, as we just learned, is: it is going to insert a row into the Customers database.0510

So, it is going to take this Customer object that was passed in, and it is going to insert it into the Customers database.0516

The way that it is done is: we have created another method within this DatabaseAccess class, called insertCustomer,0522

which works just like our insertItem method: it just takes that Customer object,0527

and then forms an INSERT query and puts it in the insert table.0534

So, it is the same standard procedure we have been doing for inserting, for example, an item into the Items table,0538

except now we are going to be inserting a Customer object into the Customer table.0546

And when it is successful, we return the updated Customer object with the custID that was generated by the AUTO_INCREMENT column of that particular table.0550

The first step we do is insert the customer; assuming that goes OK, we move on to the next part,0560

which is going to be our second INSERT, which is going to be an insert into the Orders table.0564

And so, what we are doing is: we start off by building up an Order object that we had just talked about.0570

And because its first property is an orderID, we set that equal to null, because we don't know the orderID until we have inserted it.0578

And you can see, here--well, let's look at the order constructor: the order constructor takes these parameters in this order.0587

It takes the orderID, a string for the date and time ordered, the tax rate, a string for the custID for the customer, and then the array of the ordered items.0598

We can see here that this second one is a call to the date function.0608

And what that is going to do is generate our timestamp for this particular order.0611

So, when this Order object is created, this is going to create the timestamp.0616

We have created a constant in this DatabaseAccess class called DATE_FORMAT.0619

And if we look at the constant summary for this particular class, we can see that this is a DATE_FORMAT string.0624

And what that does is allows us to properly format the string for MySQL to be able to interpret it when we try to insert it.0634

This signifies a 4-digit year, 2-digit month, 2-digit day, 2-digit hour, 2-digit minute, and 2-digit seconds.0641

And so, that way, when we go to insert it in the database, MySQL will be able to understand that string.0649

So then, after we have built up this Order object, we are going to create an INSERT statement for the Orders table.0656

And what we are going to do is just take information that we have included in this new Order object0662

and use the sprintf function to create that Order statement, and go ahead and insert that into the table.0669

Assuming there are no problems, we go ahead and update the Order object with the insert_id that was generated for it.0674

And so, now we have our customer in the Customers table; we have our row in the Orders table.0680

Now, all we need to do is loop over all of the different items that were in the order and create rows in the orders_items table.0686

Well, we have passed a shopping cart object to this particular method.0693

And so, what we are going to do is loop over all of the items in that particular cart,0699

and then extract the information we need to create an OrderItem object.0704

And we are going to build up this orders_items array.0708

And so, what we are extracting is: for each OrderItem, we are including the orderID that we had just generated0711

for the order row that we had just added to the Orders table.0718

For the itemID part of the OrderItem, we are going to pull the itemID from the CartItem object that is in our shopping cart.0721

Likewise, we are going to pull the quantity for that particular item out of the CartItem object.0730

And then, we are going to pull the price for the item out of the Item object that is in the CartItem object that is in the cart.0734

So, it gets a little bit complicated, with objects referring to objects, and so forth.0741

What we are doing is building up this OrderItem object that contains a reference to the Order, the orderID,0746

the item that is in the order, and then the price and quantity of that item when the order was made.0753

We add that for each item in our cart, so we are going to loop over the cart, and we build up that orders_items array.0759

Then, what we are going to do is loop over that array and run an INSERT statement into the orders_items table, representing each of those OrderItem objects.0767

So, for every item that we have in our shopping cart, there is going to be an INSERT into the orders_items table.0778

So, we loop over that orders_items array.0783

Assuming we don't have any problems, we go ahead and update our Order object with that array of ordered items.0786

And then, we return it to the user, so that they can pull information that they might need from that.0792

And so, the place that uses this is checkout.php, as mentioned.0799

If we go and look at checkout.php, in our previous version of checkout.php, when the user would submit0803

a form with the completeOrder action, it would build up a Customer object.0812

It would validate the Customer, and then it would call this emailOrder function, which would pass along the shopping cart,0816

which contains all of the information about all of the items and the prices and the quantities,0821

and then the Customer object, which contains information about the customer.0824

And that would return the date/time stamp.0828

Well, now what we are doing is: we are going to be replacing that.0830

We still build up a Customer object; we still validate the Customer, except now, we are going to be calling on our DatabaseAccess object.0833

We are going to be calling this insertOrder function that we just learned about.0841

We are going to pass it the shopping cart, with all of the information in the cart that is trying to be completed.0844

We are going to pass it the Customer information.0849

And we are also going to pass it the sales tax rate used for this order, which, in this particular case, is our constant sales tax rate.0851

As we just learned, insertOrder returns a built-up Order object, assuming it was successful.0859

And so, what we can do is: on that object, we can pull the dateTimeOrdered property out of that object,0866

which is that date/time stamp that we generated using the date function in PHP.0871

And we can set our order date and time equal to that.0877

And so, the rest of this script is going to work the same way.0880

Here, we had an order date and time that was set from emailOrder.0883

And then, what it does is goes ahead and processes the rest of the script, and outputs a thank-you message0887

that shows the current date and time, the current total, and so forth.0895

Now, one other thing to note about our Order and OrderItem classes is: like Cart and CartItem,0901

there is a way to calculate the total for a particular order, because, as we had mentioned in the last lesson,0910

when we have an order in the database, we don't include a column for total for the order, because that is something that we can calculate.0916

And so, if we already have all of that information in the database, there is no need to store it in there, because we can calculate it.0922

It wastes space; so the way we set up the method that has been set up to do that is:0927

each OrderItem object has a calcOrderItem total, just like we had calcCartItem total.0932

And it just multiplies the quantity of the item in the cart times its price to give you the price due to that quantity.0939

And then, in our Order class, it simply loops over all of the OrderItem objects that are in its orders_items array.0948

And in calcOrderTotal, it loops over those OrderItems, adds up a subtotal by calling that calcOrderItemTotal method0955

on each OrderItem object, and then simply multiplies that, using 1+the tax rate to get the total including tax.0962

It rounds it off, and then it returns that.0971

And that is the way that we are going to be able (in the future, and we are going to see that in a little bit)0973

to calculate an order total in the future, when we look up an order in the database.0978

These are the methods that we are going to use to do that.0983

If we look at version 19.0, which is our current version of the web store, and we go ahead and create a shopping cart,0987

and add a couple of items to it--maybe we'll add 2 T-shirts, and maybe we are going to add a DVD player to the cart;1005

now, when we go to check out, our new checkout.php script is going to run.1016

So, instead of emailing the order, it is going to insert it into the database.1020

If we go ahead and submit this order, and click Complete Order, it is going to insert it into the database.1023

We are going to see this timestamp that we were generated; it is going to tell us the order, like before.1041

It is going to be able to echo the customer information.1045

And now, if we go to our MySQL Monitor, we can look up the information in this Orders table, orders_items table,1048

and Customers table to verify, and see that it was actually added to our database.1056

Now, if we run SELECT * on our Orders table (which we created in the last required homework),1062

we can see that there is one order in the table, which is the order we just created.1070

It has orderID 1; this is the date and time stamp of when it was ordered.1074

The tax rate at the time was 10%, and it was associated with custID #1.1078

If we go and look up our information in our Customers table, we can see that (let me restrict that a little bit)1084

there is one row in our Customer table; it is Joe Smith, and has customer ID 1.1112

And we can see that that is what links this row in our Orders table to the row in the Customers table.1118

Now, we added two items to our particular cart, so we should have two rows in our orders_items linking table.1125

So, if we see all the rows in our orders_items table, we can see that there are two entries.1133

It says that item 1001 was associated with orderID 1; it had a quantity, 2;1147

the price of the item when that order was placed was $15.1153

And then, we can also see that associated with the order 1 was the item 1005, which was the DVD player.1157

We only added one of those, and its price was $79.99.1162

As you can see, this insertOrder method has gone ahead and updated our Orders table, our Customers table, and our orders_items table1166

to have all of that information in our database, via one method.1175

For example, what we are going to be showing in the next version is how we are going to view these orders.1181

And what we had learned in our last lesson was about JOINS.1189

So, let's say we want to pull, for our order, the date and time of the order, and the customer name.1192

Well, we can use a JOINS query to do that (that we learned about in our last lesson).1204

We are saying, "Select the orderID from the Orders table, the first name and last name from the Customers table,1215

from the Orders table with an alias of o, and we are going to have that table inner joined with the Customers table with an alias of c."1220

And the condition is where the custID of our Orders table equals the custID of our Customers table.1239

And we can see that, via this JOINS query, we can pull information about this order and find out that,1252

"OK, Joe Smith was the one that ordered orderID number 1."1257

So, that is how we are going to make use of our inner join query in our next version of the application, which we are going to talk about now.1260

In 19.1, we have already implemented the method to insert an order to a table.1271

What 19.1 does is adds an admin page, or two admin pages, to our administrative interface.1276

It is going to allow us to view all of the orders that have been added to the store (orders that have been made).1282

It is going to do that by a couple of different functions that we are going to add to our DatabaseAccess class.1289

We have a getOrder function, which is going to allow us to pull all of the information from those three tables1293

to build up an Order object, to extract all of that information.1299

We have a getOrders function that is going to allow us to pull an array of all of the orders in the database.1305

And there is also a getCustomer function that we are going to be creating to use in these methods, to pull information from the Customer table.1311

Our getOrder function, because it is pulling information from our Orders table and our Customers table,1320

as we just saw--it is going to make use of an inner join query.1326

And that is going to allow it to receive information from both Orders and Customers in a single result set.1329

That is the key method that we have added here, getOrders, so let's take a look at that.1336

Oops, I'm in the wrong version; that is why I couldn't find it.1358

So, if we look at our DatabaseAccess class in version 19.1, we can see the getOrder function.1371

And if we go and take a look at that, it is like our getItem or getDepartment function.1379

It takes an ID of a particular order; it takes an orderID to look it up.1383

And what you can see here is: we have a SELECT query that is an inner joined query.1388

It is a join query that joins the Orders table and the Customers table.1393

And what we are pulling up is the ID of the order, the date and the time it was ordered, and the tax rate.1397

We are pulling that from the Orders table.1403

We are pulling all of the information from the Customers table, and we do that with c.*.1407

And c is an alias for our Customers table; * says to pull all of the columns from the Customers table.1411

And we are saying, "From the Orders table," alias o, "joined with the Customers table," who has an alias of c...1417

and we are joining them on the condition; so we join those two tables--it is going to be a combination of all those rows;1425

but we are saying, "Only give us the rows where the customer ID of the Orders table matches the customer ID of the Customers table,1430

and"--because we don't just want the join of all of the different rows that match up; we also want it for a specific order,1437

we are saying, "also where the orderID of our Orders table equals the orderID passed in."1446

So, that is going to give us the result set that is going to have all of these different columns and allow us to build up an Order object.1452

So, we go ahead and run this SELECT query; we save the row using the fetch_object method from the result set that is orderCustRow.1461

And then, what we do: assuming that there wasn't an error in returning the rows, we should receive one row back.1472

Then, what we need to do is: we also need (to build up an Order object) to get all of the information from our orders_items table.1483

We have another SELECT query that is going to pull all of the columns from the orders_items table1490

that have an orderID equal to that which was passed into here.1493

And what we do is: we run that query and generate a result set.1498

And then, we are going to return an Order object that is built using this buildOrderFromRows.1502

It is a private helper function that takes the row returned from our original SELECT query,1509

that was a JOINS query from the Customers and Orders tables, and then also the result set1514

that is going to contain all of the rows from orders_items for a particular order.1519

And it is going to build up that object and return it.1523

And if we look at the source code, we can see that private method.1525

What it does is loops over all of the results from the orders_items query, builds up an OrderItem for each one of those, and adds it to an array.1534

And then, we simply build up an Order object containing information obtained from the original SELECT join query.1544

It is contained in this orderCustRow; and then, we simply add to that constructor this Items array1553

that we have built up of all of the different OrderItems.1560

And so, what that is going to allow us to do is: we are going to have a script that we are going to see in a minute called viewOrder.1563

It is going to call this getOrder function, and it is going to return this Order object, and we are going to be able to pull information about the order from that.1567

Now, we also have the getOrders function; and simply, what that does is runs a SELECT query on the Orders table,1576

and says, "Give me the orderID for all of the orders in the table."1583

Assuming that there is at least one order in the table, what it does is just builds up an array of Order objects1587

by running that getOrder function again for each order.1592

Let's take a look at what this looks like in our administrative website.1601

We can see that we have all the same links as before; we have added a new link called View Orders.1609

And actually, before I do this, let me add a little more data to our database; let's add another order.1614

So now, we are going to have two orders in our database.1640

When we go to our administrator website, we can click on this View Orders link.1644

And what that is going to do is call that getOrders function.1648

And we can see that what this script does is: after it calls getOrders, it is able parse all of the order information in there1652

and output this table that says, "These are the orders that are currently in our database."1659

There is one order that was placed at this time; this was its total.1663

And it calculates that total using the Order object calcOrderTotal function that we had talked about.1668

And we could see that there was another order placed here.1675

And then, the actual orderID links to a detail page about the particular order.1678

Before we look at that, we can look at viewOrders.php.1683

What it does, up here in the beginning section, in the data processing section: it loads all of the orders in the database, using the getOrders function.1689

And then, simply, it generates a table in the output section where it loops over each of the different orders,1696

and then outputs a link to the viewOrder page for that particular order, outputs the date and time that it was ordered,1701

and then outputs the total, which is calculated from the calcOrderTotal function.1709

Now, our viewOrder class--when we actually click on one of these links...for example, let's click on order 2; it provides details about that order.1714

We can see, orderID 2 was ordered on this date; this was its total; and it contained item 1006, quantity 1, at price $34.99.1722

Likewise, if we do it for order 1, where we had two items, we can see that item 1001 was contained in it twice.1732

The price, when it was ordered, was $15; and this one was $79.99.1738

And our viewOrder class gets passed an orderID of the order to view.1743

It loads it up from the database, using the getOrder function.1748

And then, it simply just outputs a table that contains all of that information that we just saw about the particular order.1751

And so, that is how the viewOrders and viewOrder scripts work.1757

So now, we are able to add orders to our database, and then, from the administrative side, go ahead and look at the different orders that are available.1761

That ends today's lesson; thank you for watching Educator.com--I look forward to seeing you next time.1769

Educator®

Please sign in to participate in this lecture discussion.

Resetting Your Password?
OR

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Membership Overview

  • Available 24/7. Unlimited Access to Our Entire Library.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lecture slides for taking notes.
  • Track your course viewing progress.
  • Accessible anytime, anywhere with our Android and iOS apps.