Friday, May 25, 2018

How to insert delete update data using ajax in php

1 comment
 insert delete update data using ajax in php
insert delete update data using ajax in php

Hi everyone, In this tutorial we will learn how to create insert delete update data using ajax in php and fetching data from database without reload the page. In order to do this task i have used jquery Ajax function to perform a asynchronous HTTP request. More over in order to fetch data without refresh the page from database i have used ajax load method with setInterval.

Here is the DEMO


Step 1 - Create Database



Step 2 - Database Connection


Let's create an index page to display all records from database. In order to do ajax performance, we need to load the jquery library. make sure load latest jquery library to index page. the bellow code showing complete script of index page. In this tutorial for easy customization purpose I have performed insert, delete and update record with bootstrap modal. so you can find the entire modal code in below snippet.


Step 3 - Insert into database


now, let's create add_warehouse.php and add below codes.


Step 4 - Fetch data without reload


To fetch data from database without refresh the page, I have used ajax load method with jquery setInterval function. what does it do? yes, it will look for page call fetch_warehouse.php and display them within given time in setInterval function. let's create fetch_warehouse.php


Step 5 - Delete data from database


The below code is receiving an ajax request from index page and deleting data from MySQL table without refresh the page.


Step 6 - Edit




From this tutorial we learned how to insert delete update data using ajax in php, hope you understood well. still you can use this source code in you project. if you have suggestion do comment or feel free contact me via Webriderat@gmail.com. happy coding.
if you found this useful please share with your firends and social media. the complete sourse code of insert delete update data using ajax in php added below to download.

If You Enjoyed This, Take 5 Seconds To Share It

1 comment:

  1. Nice post, thanks for sharing.

    it would have been nice to add the validation of the posted fields to make sure that the values are accepted by the sql query

    ReplyDelete