PHP for Beginners – Part 5



php-for-beginners

Hey Guys!!!  This is the last part of the tutorial series. In this tutorial you will learn to create a database, connect your database with PHP, and query the database(MySql) using SQL to insert,update,delete records. If you want to learn SQL you can learn form w3schools. After the end of this tutorial series you will surely not be a beginner in PHP language.

Download “php-for-beginners-sample-database-script.zip” php-for-beginners-sample-database-script.zip – Downloaded 935 times – 7 KB

The first thing that you open phpMyAdmin, and create a database  say “MyDatabase“.  Then create a table named “testdatabase” and insert some data so you can play with them.Given below is the SQL for creating a table and inserting some records.

How to include one file within another file

There are 4 types of function that we can choose for including a file in another file:

  • include – It will always include the file, irrespective if file was included earlier,  gives a warning if could not find the file and continues the script
  • include_once – – It will include the file only if file was not included earlier, gives a warning if could not find the file and continues the script
  • require – It will always include the file, irrespective if file was included earlier,  stops the script if file not found.
  • require_once – It will include the file only if file was not included earlier,  stops the script if file not found.

If you have some critical file that is very necessary for the script, like database connection file, use require function. If you have some template file for html designing purpose you can use include function. If you want to include a file which include common function use include_once or including a function file multiple time will gives “function redeclare” error.



Create a configure file to get started.

Create an index.php file which will be like home page for all your project.

Different methods to fetch data from the database.

For adding a new player click on the Add new player link it will redirect to insert.php page where you can add as many player as you like.

To edit a player click on the edit link on the listing. It will redirect you to the edit.php form where you can edit the player data.

Finally to delete a player click on the delete link on the listing page, it will redirect you to the delete.php which will delete the player record.

Download “php-for-beginners-sample-database-script.zip” php-for-beginners-sample-database-script.zip – Downloaded 935 times – 7 KB

Hope this code helps you. 🙂



Was this article/content helpful?
Thanks! Your feedback helps us to improve PHPHive.info

Leave a Reply

Your email address will not be published. Required fields are marked *