Saturday, 26 January 2013

This is my first practical tutorial using PHP/MYSQL. If you want to add a simple add/edit/delete functionality to category listing page. Then, first if all you have to create 5 php files as given below:

1. db_connect.php

2. add_category.php

3. edit_category.php

4. delete_category.php

5. view_category.php

We also need a table to create with the following structure given in below given image:

Table Structure

Now, let me describe the use of all these files.

Step 1:

"db_connect.php" is created in order to create a database connection between PHP & MYSQL. The file contains the below given code.

Here, "ebuksmania" is the name of the database, "localhost" is the name of the host/server and "root" is the username. This file is included in all the other php files as database connectivity is needed in other php files and this file will provide database connectivity to other files.

Step 2:

"add_category.php" is created in order to add category to the specified category table in MYSQL. The file contains the below given code.