HTML5 Inline Editing with PHP, MYSQL & jQuery Ajax

This tutorial help to understand HTML5 inline editing with PHP and MYSQL,in Previous tutorial HTML inline editing,We have learn how to create any HTML control inline editable using contenteditable attribute.Inline Editable will work on only HTML5 supported browser.

There are a lot of jQuery plugin which also provide inline editable functionality but using HTML5 you can do very easily without any overhead of jquery library.You just need some ajax jquery coding to update data into MySQL database to update record.This will help on single column updated instead of whole form data.

html5 inline editing with php demo

How will Work inline Editing with HTML5,PHP and Mysql

We will create listing all records into table.We will add contenteditable attribute on all 'td's (

) of table where i need provide inline editable functionality.

Whenever user will change TD data, i will capture event 'focusout' using jQuery and get updated data of td, finally call php function to updated data into mysql using changed td data.

Following files will participate in this example

  1. connection.php : This file used to create connection with mysql
  2. index.php : This file used to display records into table and inline editing option
  3. server.php : This file will call on ajax request and update data into mysql

Also checkout other related tutorials,

Step 1: include bootstrap css file and jQuery library into head section of page.

Step 2: Created Connection file connection.php for database connection with php.

Step 3: Get records from mysql and store in variable,put below code into index.php file.

Here i am featching data from mysql for display data into HTML table.You need to replace table name 'employee' with your table name.

Step 3: Create html table and iterate records into row.

Here i am using step-2 $queryRecords variable and iterate on tr using php foreach() function to display table data,You can see i have added hard coded col-index='*' attribute on each table td for identification of column name.I have also addaed oldVal='*' attribute to store old valve of table, if the new and old value is same we will not send server request.
i am also adding data-row-id="" attribute on on each tr of table to indentify row-id of data.This 'id' will be primary key of employee table.This tells for which row of column we are updating.

Step 4: Created AjAX jquery request to update data into mysql using server side php script.

Here You can see i am attaching event 'focusout' on each td of table and send request if the value of td changed, first I am getting changed value td and then get row-id of data tuple with column-id.Aggregate all params and send to server for update column value.

Step 5: Now update data into mysql using server.php.

This is a simple code php code , i haven’t added sql injection prevent code and not combined all validate conditions into complex php code.


I have explain how to implement HTML5 inline editing with PHP,MYSQL and jQuery AJAX.You can easily integrate inline editing with in your application using HTML5 contenteditable attribute.

Download Code and Demo Link