A Complete PHP MySQL Tutorial

Hello world :)

This site will give you a definite how to in order for you to build a standalone database supported web application using PHP and MySQL. This is meant as a complete tutorial and will take you by the hand step by step through all you need for a minimal PHP and MySQL based web application.

I will go into infrastructure basics as well as database concept foundations and step-by-step HTML notation and PHP programming exercises.

Who am I?

I am Erik, carrying a Bachelor’s degree in business informatics, a Master’s degree in information security and a PhD in federated information security management. I am an IT professional for several years, I’m holding a CISSP certification and I spent several years teaching database development courses at University of Applied Sciences Brandenburg, Germany.

Erik speaking in front of business audience

Erik @ SAP Startup Forum, Berlin, Germany

I am honored to be your guide :)

The idea behind modern web development

Ever since the concept “web 2.0” came up, the user was meant to participate in the content delivery of a modern web page. For example, a user can take part in content creation by:

  • posting a comment underneith a blog post
  • posting a guest book entry on someones personal website
  • posting a statement to a community forum
  • posting texts to a Wiki
  • uploading media (images or videos) to a social network
  • sharing documents with team mates in a web collaboration system
  • changing attribute values of data sets in a global music library
  • adding or deleting items within a geo caching record system

All of the above require data handling capabilities of the web site in question. A web site is no longer a static item delivering simple hard coded structured data via HTML. Web 2.0 web pages require dynamic data display. To achieve that, communication between the web server and a database server which delivers the ever changing data is required.

Between the ideas of delivering structured display data via HTML and managing data coming from a database system such as MySQL, PHP is used to introduce various algorithms such as loops and data sorting functions. Using databases like MySQL to hold data and HTML as a way to formulate visual markup, PHP is the binding element for both sides to understand each other.

A HTML form may present a way to input guest book data such as your name and your entry text. PHP then reads that data and passes it to the database. The database system then inserts the data received from PHP to the pre-defined database tables. Another web page can then use PHP to read the content of a specific database table, or even different tables combined, and present that data, e.g. the guest book content, including the newly created entry. PHP then not only handles the data readout, but it also generates the HTML output you desire.

Now that must all sound pretty horrible. Actually it’s not. All the concepts above will be explained in more detail using the following tutorial.

A PHP MySQL tutorial

In order for you to grasp everything you need to know about PHP and database development, I recommend going through this tutorial step by step. Therefor I developed the following sections in chronological order.

  1. Client and Server Infrastructure: File, Web, Database
  2. Relational Database Management System Basics
  3. Database Modelling and Structurization
  4. VI Editor in Unix
  5. HTML Coding Basics
  6. HTML form elements
  7. Learning PHP: programming basics for output, calculation and variables
  8. PHP for loops and conditions
  9. How to use PHP functions
  10. PHP GET and POST parameters
  11. How to build a website — PHP navigational skeleton step by step
  12. How to connect to MySQL using PHP
  13. PHP Login Script Tutorial
  14. Dynamic PHP based MySQL data readout with HTML output

Whenever you have a question, feel free to get back here.

PHP and database development for dummys

This guide is scructured in a way that it can serve as a reference sheet reagarding certain source code or concept ideas even when you already know how to code. Still, this guide does not require you to have any skills to start using it. In fact the material in front of you was used for basic University programming and database classes — with great success and feedback.

However, due to bad experience, I must ask you to use this tutorial for private purpose only. Please respect my authorship and do not download my images for the purpose of uploading them elsewhere. Also, please don’t copy my code or texts in order to publish them on a different website. Stay fair. Thank you!

Finally, please also note that although my focus is on information security, I will not go into details on PHP or database security issues at this point. This PHP MySQL tutorial is meant as a full guide for you to learn walking, not running.

PHP MySQL tutorial

For details regarding security, usability and other related topics please refer to other guides as well after you are able to develop the kind of website you seek to be able to create.

You can direct any comments and questions regarding this tutorial to me at any time.

Have fun! :-)