Build Your Own Database Driven Web Site Using PHP & MySQL, Fourth Edition

Share this article

Who Should Read this Series?

This article series is aimed at intermediate and advanced web designers looking to make the leap into server-side programming. You’ll be expected to be comfortable with simple HTML, as I’ll make use of it without much in the way of explanation. No knowledge of Cascading Style Sheets (CSS) or JavaScript is assumed or required, but if you do know JavaScript, you’ll find it will make learning PHP a breeze, since these languages are quite similar.

By the end of this series, you can expect to have a grasp of what’s involved in building a database driven web site. If you follow the examples, you’ll also learn the basics of PHP (a server-side scripting language that gives you easy access to a database, and a lot more) and Structured Query Language (SQL – the standard language for interacting with relational databases) as supported by MySQL, the most popular free database engine available today. Most importantly, you’ll come away with everything you need to start on your very own database driven site!

What’s in this Series?

This series comprises the following 4 chapters. Read them in order from beginning to end to gain a complete understanding of the subject, or skip around if you need a refresher on a particular topic.

Chapter 1: Installation

Before you can start building your database driven web site, you must first ensure that you have the right tools for the job. In this first chapter, I’ll tell you where to obtain the two essential components you’ll need: the PHP scripting language and the MySQL database management system. I’ll step you through the setup procedures on Windows, Linux, and Mac OS X, and show you how to test that PHP is operational on your web server.

Chapter 2: Getting Started with MySQL

Although I’m sure you’ll be anxious to start building dynamic web pages, I’ll begin with an introduction to databases in general, and the MySQL relational database management system in particular. If you have never worked with a relational database before, this should definitely be an enlightening chapter that will whet your appetite for what’s to come! In the process, you’ll build up a simple database to be used in later chapters.

Chapter 3: Introducing PHP

Here’s where the fun really starts. In this chapter, I’ll introduce you to the PHP scripting language, which you can use to build dynamic web pages that present up-to-the-moment information to your visitors. Readers with previous programming experience will probably only need a quick skim of this chapter, as I explain the essentials of the language from the ground up. This is a must-read chapter for beginners, however, as the rest of this book relies heavily on the basic concepts presented here.

Chapter 4: Publishing MySQL Data on the Web

In this chapter you’ll bring together PHP and MySQL, which you’ll have seen separately in the previous chapters, to create some of your first database driven web pages. You’ll explore the basic techniques of using PHP to retrieve information from a database and display it on the Web in real time. I’ll also show you how to use PHP to create web-based forms for adding new entries to, and modifying existing information in, a MySQL database on the fly.

The Book

Build Your Own Database Driven Web Site Using PHP & MySQL 4th Edition Cover

The four chapters in this series are actually only the first part of this book. Build Your Own Database Driven Website Using PHP & MySQL contains not only the four chapters above, but eight more chapters that cover advanced database concepts, the design of a complete content management system, MySQL server administration, and much, much more! The book also includes a complete set of appendices to make it the ideal desk reference for PHP and MySQL Web development. For more information, see the book page.

If you prefer to read the Adobe Acrobat PDF version of these first four chapters, you can Download the first Four Chapters FREE.

Your Feedback

If you have a question about any of the information covered in this series, your best chance of a quick response is to post your query in the SitePoint.com Forums.

If you can’t find your answer through the forums, or if you wish to contact me for any other reason, the best place to write is here. We have a well-manned email support system set up to track your inquiries, and if our support staff is unable to answer your question, they send it straight to me. Suggestions for improvement as well as notices of any mistakes you may find are especially welcome.

And so, without further ado, let’s get started!

If you enjoyed reading this post, you’ll love Learnable; the place to learn fresh skills and techniques from the masters. Members get instant access to all of SitePoint’s ebooks and interactive online courses, like PHP & MySQL Web Development for Beginners.
Go to page: 1 | 2

Frequently Asked Questions about PHP & MySQL Tutorial

What are the prerequisites for learning PHP and MySQL?

Before you start learning PHP and MySQL, it’s beneficial to have a basic understanding of HTML and CSS. Knowledge of JavaScript can also be helpful but is not mandatory. Familiarity with basic programming concepts like variables, loops, and functions is also advantageous. However, even if you’re a complete beginner, you can still learn PHP and MySQL. The tutorial is designed to be easy to understand and follow.

How can I install PHP and MySQL on my computer?

To install PHP and MySQL on your computer, you can use software packages like XAMPP, WAMP, or MAMP. These packages contain Apache (a web server), MySQL (a database), and PHP. They are easy to install and set up. After installation, you can start building your PHP and MySQL applications locally on your computer.

How can I connect to a MySQL database using PHP?

To connect to a MySQL database using PHP, you can use the mysqli_connect() function. This function takes four parameters: the hostname, the username, the password, and the database name. If the connection is successful, it returns a MySQL link identifier that you can use for further operations. If the connection fails, it returns false.

How can I retrieve data from a MySQL database using PHP?

To retrieve data from a MySQL database using PHP, you can use the mysqli_query() function. This function executes a query against the database and returns a result set that you can fetch using functions like mysqli_fetch_assoc() or mysqli_fetch_array().

How can I insert data into a MySQL database using PHP?

To insert data into a MySQL database using PHP, you can use the mysqli_query() function. You need to write an INSERT INTO statement and pass it to the mysqli_query() function. If the query is successful, it returns true. If it fails, it returns false.

How can I update data in a MySQL database using PHP?

To update data in a MySQL database using PHP, you can use the mysqli_query() function. You need to write an UPDATE statement and pass it to the mysqli_query() function. If the query is successful, it returns true. If it fails, it returns false.

How can I delete data from a MySQL database using PHP?

To delete data from a MySQL database using PHP, you can use the mysqli_query() function. You need to write a DELETE FROM statement and pass it to the mysqli_query() function. If the query is successful, it returns true. If it fails, it returns false.

How can I handle errors in PHP and MySQL?

PHP has built-in functions for handling errors. You can use the die() function to stop the script execution and display an error message. For MySQL errors, you can use the mysqli_error() function, which returns the last error description for the most recent function call.

How can I secure my PHP and MySQL applications?

To secure your PHP and MySQL applications, you should always validate and sanitize user input, use prepared statements or parameterized queries to prevent SQL injection, and store passwords securely using PHP’s password_hash() function.

Where can I find more resources to learn PHP and MySQL?

There are many online resources to learn PHP and MySQL. You can find tutorials, documentation, and online courses on websites like PHP.net, MySQL.com, W3Schools, and Stack Overflow. You can also find books on Amazon and other online bookstores.

Kevin YankKevin Yank
View Author

Kevin Yank is an accomplished web developer, speaker, trainer and author of Build Your Own Database Driven Website Using PHP & MySQL and Co-Author of Simply JavaScript and Everything You Know About CSS is Wrong! Kevin loves to share his wealth of knowledge and it didn't stop at books, he's also the course instructor to 3 online courses in web development. Currently Kevin is the Director of Front End Engineering at Culture Amp.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week