Skip to content

Commit f3ab469

Browse files
authored
Update README.md
1 parent 961c859 commit f3ab469

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,33 @@ The PHP Data Objects (PDO) extension defines a consistent, lightweight interface
66
This PHP PDO example, implements a simple PHP CRUD operation, learning PDO connection, PDO insert, PDO select, PDO update, PDO delete query management. The example provides a simple Web view, add, edit, and delete functionality with PHP OOP using PDO MySQL.
77

88
In this example script, we’ll fetch the users data from the database and display the user data list with add link, edit link, and delete link. By these links user can add new data to the database, update previously inserted data and delete the data from the database. We’ll use Object oriented approach to building the example script and bootstrap table structure for styling the list, form fields, and links.
9+
10+
### Database Table Creation
11+
For this example application, we’ll create a simple table (users) with some basic columns where users data would be stored.
12+
13+
### Database Class (dbclass.php)
14+
DB class handles all the operations related to the database using PHP PDO extension and MySQL. For example, connect with the database, insert, update and delete the record from the database. You need to change the $dbHost, $dbUsername, $dbPassword, and $dbName variables value as per the database credentials.
15+
16+
### Action - action.php (insert, update, delete records)
17+
This file handles the requests coming from the HTML page using DB class. Based on the request, user data would add, update, delete to the database. Here the code is executed based on the action_type. action_type would be three types, add, edit, and delete. The following operations can happen based on the action_type.
18+
add insert the record in the database, status message store into the session and return to the list page.
19+
edit updates the record in the database status message store into the session and return to the list page.
20+
delete deletes the record from the database status message store into the session and return to the list page.
21+
22+
### Index - index.php
23+
This is the main listing page where all the users are listed with add, edit, and delete links.
24+
25+
#### Bootstrap libraries:
26+
Bootstrap CSS & JS library need to be included if you want to use Bootstrap table and form structure, otherwise, omit it.
27+
28+
`<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
29+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>`
30+
31+
Include the dbclass.php file for using the DB class to fetch the users data from the database using PDO and MySQL.
32+
33+
### Add Data - add.php
34+
In this file, an HTML form would display to collecting the user data and submitted to the action.php file. Also, a hidden field would be submitted with the respective action_type.
35+
36+
### Edit Data - edit.php
37+
In this file, an HTML form would display with existing user data and submitted to the action.php file. Also, two hidden fields would be submitted with the respective action_type and user id.
38+

0 commit comments

Comments
 (0)