Simple Demo of jTable Add,Edit and Delete Using PHP and MySQL

In previous tutorial, we have learn jTable features and integration with php and MySQL.This jTable tutorial is second part of Simple Example of JTable With PHP and MySQL, We will implement AJAX based add,edit and delete record from MySQL database using php and jTable.

jTable is very well documented jQuery grid table plugin and help to create AJAX based CRUD tables.You can easily implement insert record,update and delete record functionality using php and MySQL. There is inbuilt call back function which will handle your add, edit and delete record request.

I am assuming you have read my previous tutorial of JTable With PHP and MySQL , so i am extending previous tutorial code and adding CRUD features on that source code.

jtable-add-edit-with-php-and-mysql

Insert Record into jQuery jTable Using PHP and MySQL

We will create one record data and insert into mysql table using php.We will show newly created data in jTable listing.

Step 1: We will add insert callback url into jTable instance using createAction option.

I have added action file name with action name, The php file is response.php and passed action name is action=create using query parameters. I will get this params into response.php file to identify which operation will perform.

Step 2: Added one more condition into php switch method in response.php file for create action.

I have called insertEmployee() method on action of insert record, This method will responsible to create new record into MySQL table.

Step 3: We will create insertEmployee() action method in response.php file.

This method will get all POST parameters for insert record and passed to MySQL insert query, once record successfully created, we will send created row data as a response.

Update Record into jTable Using PHP and MySQL

Step 1: We will add update callback url into jTable instance using updateAction param.

We have passed action name is update like action=update.

Step 2: Added one more condition into switch method in response.php file.

We have called updateEmployee() method on updated record event.

Step 3: We will create new action method updateEmployee() in response.php file to update record in MySQL.

I created update SQL query using posted data and run using MySQL query method.We have send updated row json data in response.

How to Implement Delete Record in jTable Using PHP and MySQL

Step 1: We will add delete callback url and added action method with in into jTable instance.

Step 2: Added a switch condition into response.php file.

Step 3: Added action method in response.php file

This method create delete row query and run query using php.

You can download source code and Demo from below link.

Conclusion :

In previous tutorial, we have learn about basic of jTable jquery grid plugin with PHP and MySQL and display records into jtable grid.This tutorials help to add, edit and delete functionality of jTable with php and MySQL using AJAX.