Build CRUD Application PHP & Mysql
Starting from today lesson we will begin to build simplest web application with php and mysql. It will be use sport database, which we created last lessons. Today we’ll define structure of our app, write script to connect with database and build html skeleton of our application
The structure is below:
- Config – connect with database (db.php)
- Teams (teams.php) – list of teams with the possibility of editing information about team
- Players (players.php) – list of players with the possibility of editing information about player
- Countries (countries.php) – list of teams by countries.
In my projects I use PDO for work with databases. There are another variants, for example, mysql and mysqli. I notice, that mysql extension is deprecated from php 5.5 and removed from php 7.
Why do I use PDO? PDO is universal decision for working with databases. It can work with different databases. And it is easy to change database in your application. Next details with PDO working we will consider in next lessons, while writing code of our app.
Also you will know about try.catch construction. When can you use it? There are arise different errors (logical and so on), but sometimes you can provide for and handle this errors. For example, you may understand, attempt with database connection can finish with error. This error you need to provide.
After success connection we will write html skeleton of our app using bootstrap and jquery.