O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SamsTeachYourself PHP, MySQL & JavaScript: All in One, 6th Edition

Book Description

In just a short time, you can learn how to use PHP, MySQL, and JavaScript together to create dynamic, interactive websites and applications using three leading web development technologies.

No previous programming experience is required. Using a straightforward, step-by-step approach, each lesson in this book builds on the previous ones, enabling you to learn the essentials of full-stack web application development – from HTML, CSS, and JavaScript on the front end, to PHP scripting and MySQL databases on the server.

Regardless of whether you run Linux, Windows, or MacOS, the book includes complete instructions to install all the software you need to set up a stable environment for learning, testing, and production.

Step-by-step instructions carefully walk you through the most common web application development tasks.

Practical, hands-on examples show you how to apply what you learn.

Quizzes and exercises help you test your knowledge and stretch your skills.

Learn how to:

  • Build web pages with HTML5 and CSS
  • Use JavaScript to build dynamic, interactive web pages
  • Get PHP, MySQL, and JavaScript to work together to create modern, standards-compliant web applications
  • Enhance interactivity with AJAX
  • Leverage JavaScript libraries such as jQuery
  • Work with cookies and user sessions
  • Get user input with web-based forms
  • Use basic SQL commands
  • Interact with the MySQL database using PHP
  • Write maintainable code and get started with version control
  • Decide when frameworks such as Bootstrap, Foundation, React, Angular, and Laravel can be useful
  • Create a web-based discussion forum or calendar
  • Add a storefront and shopping cart to your site

Contents at a Glance

PART I Web Application Basics

1 Understanding How the Web Works

2 Structuring HTML and Using Cascading Style Sheets

3 Understanding the CSS Box Model and Positioning

4 Introducing JavaScript

5 Introducing PHP

PART II Getting Started with Dynamic Web Sites

6 Understanding Dynamic Web Sites and HTML5 Applications

7 JavaScript Fundamentals: Variables, Strings, and Arrays

8 JavaScript Fundamentals: Functions, Objects, and Flow Control

9 Understanding JavaScript Event Handling

10 The Basics of Using jQuery

PART III Taking Your Web Applications to the Next Level

11 AJAX: Getting Started with Remote Scripting

12 PHP Fundamentals: Variables, Strings, and Arrays

13 PHP Fundamentals: Functions, Objects, and Flow Control

14 Working with Cookies and User Sessions

15 Working with Web-Based Forms

PART IV Integrating a Database into Your Applications

16 Understanding the Database Design Process

17 Learning Basic SQL Commands

18 Interacting with MySQL Using PHP

PART V Getting Started with Application Development

19 Creating a Simple Discussion Forum

20 Creating an Online Storefront

21 Creating a Simple Calendar

22 Managing Web Applications

PART VI Appendixes

A Installation QuickStart with XAMPP

B Installing and Configuring MySQL

C Installing and Configuring Apache

D Installing and Configuring PHP

Table of Contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. About This E-Book
  5. Contents at a Glance
  6. Table of Contents
  7. Introduction
  8. Part I: Web Application Basics
    1. CHAPTER 1: Understanding How the Web Works
      1. A Brief History of HTML and the World Wide Web
      2. Creating Web Content
      3. Understanding Web Content Delivery
      4. Selecting a Web Hosting Provider
      5. Testing with Multiple Web Browsers
      6. Creating a Sample File
      7. Using FTP to Transfer Files
      8. Understanding Where to Place Files on the Web Server
      9. Summary
      10. Q&A
      11. Workshop
    2. CHAPTER 2: Structuring HTML and Using Cascading Style Sheets
      1. Getting Started with a Simple Web Page
      2. HTML Tags Every Web Page Must Have
      3. Using Hyperlinks in Web Pages
      4. Organizing a Page with Paragraphs and Line Breaks
      5. Organizing Your Content with Headings
      6. Understanding Semantic Elements
      7. How CSS Works
      8. A Basic Style Sheet
      9. A CSS Style Primer
      10. Using Style Classes
      11. Using Style IDs
      12. Internal Style Sheets and Inline Styles
      13. Summary
      14. Q&A
      15. Workshop
    3. CHAPTER 3: Understanding the CSS Box Model and Positioning
      1. The CSS Box Model
      2. The Whole Scoop on Positioning
      3. Controlling the Way Things Stack Up
      4. Managing the Flow of Text
      5. Understanding Fixed Layouts
      6. Understanding Fluid Layouts
      7. Creating a Fixed/Fluid Hybrid Layout
      8. Considering a Responsive Web Design
      9. Summary
      10. Q&A
      11. Workshop
    4. CHAPTER 4: Introducing JavaScript
      1. Learning Web Scripting Basics
      2. How JavaScript Fits into a Web Page
      3. Exploring JavaScript’s Capabilities
      4. Basic JavaScript Language Concepts
      5. JavaScript Syntax Rules
      6. Using Comments
      7. Best Practices for JavaScript
      8. Understanding JSON
      9. Using the JavaScript Console to Debug JavaScript
      10. Summary
      11. Q&A
      12. Workshop
    5. CHAPTER 5: Introducing PHP
      1. How PHP Works with a Web Server
      2. The Basics of PHP Scripts
      3. Code Blocks and Browser Output
      4. Summary
      5. Q&A
      6. Workshop
  9. Part II: Getting Started with Dynamic Websites
    1. CHAPTER 6: Understanding Dynamic Websites and HTML5 Applications
      1. Refresher on the Different Types of Scripting
      2. Displaying Random Content on the Client Side
      3. Understanding the Document Object Model
      4. Using window Objects
      5. Working with the document Object
      6. Accessing Browser History
      7. Working with the location Object
      8. More About the DOM Structure
      9. Working with DOM Nodes
      10. Creating Positionable Elements (Layers)
      11. Hiding and Showing Objects
      12. Modifying Text Within a Page
      13. Adding Text to a Page
      14. Changing Images Based on User Interaction
      15. Thinking Ahead to Developing HTML5 Applications
      16. Summary
      17. Q&A
      18. Workshop
    2. CHAPTER 7: JavaScript Fundamentals: Variables, Strings, and Arrays
      1. Using Variables
      2. Understanding Expressions and Operators
      3. Data Types in JavaScript
      4. Converting Between Data Types
      5. Using String Objects
      6. Working with Substrings
      7. Using Numeric Arrays
      8. Using String Arrays
      9. Sorting a Numeric Array
      10. Summary
      11. Q&A
      12. Workshop
    3. CHAPTER 8: JavaScript Fundamentals: Functions, Objects, and Flow Control
      1. Using Functions
      2. Introducing Objects
      3. Using Objects to Simplify Scripting
      4. Extending Built-in Objects
      5. Using the Math Object
      6. Working with Math Methods
      7. Working with Dates
      8. The if Statement
      9. Using Shorthand Conditional Expressions
      10. Testing Multiple Conditions with if and else
      11. Using Multiple Conditions with switch
      12. Using for Loops
      13. Using while Loops
      14. Using do…while Loops
      15. Working with Loops
      16. Looping Through Object Properties
      17. Summary
      18. Q&A
      19. Workshop
    4. CHAPTER 9: Understanding JavaScript Event Handling
      1. Understanding Event Handlers
      2. Using Mouse Events
      3. Using Keyboard Events
      4. Using the load and unload Events
      5. Using click to Change a <div>'s Appearance
      6. Summary
      7. Q&A
      8. Workshop
    5. CHAPTER 10: The Basics of Using jQuery
      1. Using Third-Party JavaScript Libraries
      2. jQuery Arrives on the Scene
      3. Preparing to Use jQuery
      4. Becoming Familiar with the $().ready Handler
      5. Selecting DOM and CSS Content
      6. Manipulating HTML Content
      7. Putting the Pieces Together to Create a jQuery Animation
      8. Handling Events with jQuery
      9. Summary
      10. Q&A
      11. Workshop
  10. Part III: Taking Your Web Applications to the Next Level
    1. CHAPTER 11: AJAX: Remote Scripting
      1. Introducing AJAX
      2. Using XMLHttpRequest
      3. Creating a Simple AJAX Library
      4. Creating an AJAX Quiz Using the Library
      5. Debugging AJAX-Based Applications
      6. Using jQuery’s Built-in Functions for AJAX
      7. Summary
      8. Q&A
      9. Workshop
    2. CHAPTER 12: PHP Fundamentals: Variables, Strings, and Arrays
      1. Variables
      2. Data Types
      3. Using Expressions and Operators
      4. Constants
      5. Understanding Arrays
      6. Creating Arrays
      7. Some Array-Related Constructs and Functions
      8. Summary
      9. Q&A
      10. Workshop
    3. CHAPTER 13: PHP Fundamentals: Functions, Objects, and Flow Control
      1. Calling Functions
      2. Defining a Function
      3. Returning Values from User-Defined Functions
      4. Understanding Variable Scope
      5. Saving State Between Function Calls with the static Statement
      6. More About Arguments
      7. Testing for the Existence of a Function
      8. Creating an Object
      9. Object Inheritance
      10. Switching Flow
      11. Implementing Loops
      12. Summary
      13. Q&A
      14. Workshop
    4. CHAPTER 14: Working with Cookies and User Sessions
      1. Introducing Cookies
      2. Setting a Cookie
      3. Deleting a Cookie
      4. Overview of Server-Side Sessions
      5. Working with Session Variables
      6. Destroying Sessions and Unsetting Session Variables
      7. Using Sessions in an Environment with Registered Users
      8. Summary
      9. Q&A
      10. Workshop
    5. CHAPTER 15: Working with Web-Based Forms
      1. How HTML Forms Work
      2. Creating a Form
      3. Accepting Text Input
      4. Naming Each Piece of Form Data
      5. Labeling Each Piece of Form Data
      6. Grouping Form Elements
      7. Exploring Form Input Controls
      8. Using HTML5 Form Validation
      9. Submitting Form Data
      10. Accessing Form Elements with JavaScript
      11. Accessing Form Elements with PHP
      12. Using Hidden Fields to Save State in Dynamic Forms
      13. Sending Mail on Form Submission
      14. Summary
      15. Q&A
      16. Workshop
  11. Part IV: Integrating a Database into Your Applications
    1. CHAPTER 16: Understanding the Database Design Process
      1. The Importance of Good Database Design
      2. Types of Table Relationships
      3. Understanding Normalization
      4. Following the Design Process
      5. Summary
      6. Q&A
      7. Workshop
    2. CHAPTER 17: Learning Basic SQL Commands
      1. Learning the MySQL Data Types
      2. Learning the Table-Creation Syntax
      3. Using the INSERT Statement
      4. Using the SELECT Statement
      5. Using WHERE in Your Queries
      6. Selecting from Multiple Tables
      7. Using the UPDATE Statement to Modify Records
      8. Using the REPLACE Statement
      9. Using the DELETE Statement
      10. Frequently Used String Functions in MySQL
      11. Using Date and Time Functions in MySQL
      12. Summary
      13. Q&A
      14. Workshop
    3. CHAPTER 18: Interacting with MySQL Using PHP
      1. MySQL or MySQLi?
      2. Connecting to MySQL with PHP
      3. Working with MySQL Data
      4. Summary
      5. Q&A
      6. Workshop
  12. Part V: Getting Started with Application Development
    1. CHAPTER 19: Creating a Simple Discussion Forum
      1. Designing the Database Tables
      2. Creating an Include File for Common Functions
      3. Creating the Input Forms and Scripts
      4. Displaying the Topic List
      5. Displaying the Posts in a Topic
      6. Adding Posts to a Topic
      7. Modifying the Forum Display with JavaScript
      8. Summary
      9. Q&A
      10. Workshop
    2. CHAPTER 20: Creating an Online Storefront
      1. Planning and Creating the Database Tables
      2. Displaying Categories of Items
      3. Displaying Items
      4. Using JavaScript with an Online Storefront
      5. Summary
      6. Q&A
      7. Workshop
    3. CHAPTER 21: Creating a Simple Calendar
      1. Building a Simple Display Calendar
      2. Creating the Calendar in JavaScript
      3. Summary
      4. Q&A
      5. Workshop
    4. CHAPTER 22: Managing Web Applications
      1. Understanding Some Best Practices in Web Application Development
      2. Writing Maintainable Code
      3. Implementing Version Control in Your Work
      4. Understanding the Value and Use of Code Frameworks
      5. Summary
      6. Q&A
      7. Workshop
  13. Appendix A: Installation QuickStart Guide with XAMPP
    1. Using Third-Party Installation Packages
    2. Installing XAMPP on Linux/UNIX
    3. Installing XAMPP on Windows
    4. Installing XAMPP on Mac OS X
    5. Securing XAMPP
    6. Troubleshooting
  14. Appendix B: Installing and Configuring MySQL
    1. Current and Future Versions of MySQL
    2. How to Get MySQL
    3. Installing MySQL on Linux/UNIX
    4. Installing MySQL on Mac OS X
    5. Installing MySQL on Windows
    6. Troubleshooting Your Installation
    7. Basic Security Guidelines
    8. Introducing the MySQL Privilege System
  15. Appendix C: Installing and Configuring Apache
    1. Current Versions of Apache
    2. Choosing the Appropriate Installation Method
    3. Installing Apache on Linux/UNIX
    4. Installing Apache on Mac OS X
    5. Installing Apache on Windows
    6. Apache Configuration File Structure
    7. Apache Log Files
    8. Apache-Related Commands
    9. Starting Apache for the First Time
    10. Troubleshooting
  16. Appendix D: Installing and Configuring PHP
    1. Current and Future Versions of PHP
    2. Building PHP on Linux/UNIX with Apache
    3. Installing PHP on Mac OS X
    4. Installing PHP on Windows
    5. php.ini Basics
    6. Testing Your Installation
    7. Getting Installation Help
  17. Index