PHP Inline Deleting Data using jQuery AJAX
Submitted by alpha_luna on Tuesday, September 6, 2016 - 14:59.
In the previous tutorial, we have done for the tutorials of Inline Editing Data and Inline Adding Data. This simple tutorial, we are going to perform the Delete function. This kind of simple tutorial suited for the beginners who want to learn delete function
You can also check the live demo of this simple tutorial, so you can get an idea and you can try this out, let's start coding.
DELETE Statement
Use this simple Delete Statement to delete the data in the database. Copy and paste this into your editor and save it as "delete.php".
Create HTML Content
This simple source code shows the simple content that we have where the user can delete data in the table.
- <?php
- require_once("database.php");
- $result_query = new DeleteInlineForm();
- $id = $_POST['id'];
- $query = "DELETE FROM tbl_products_inline WHERE id = '$id' ";
- $result_query->executeQuery($query);
- }
- ?>
- <table class="tbl-qa">
- <thead>
- <tr>
- </tr>
- </thead>
- <tbody id="table-body">
- <?php
- if(!empty($row_product)) {
- foreach($row_product as $k=>$v) {
- ?>
- <tr class="table-row" id="table-row-<?php echo $row_product[$k]["id"]; ?>">
- <td contenteditable="true" onBlur="saveToDatabase(this,'product_name','<?php echo $row_product[$k]["id"]; ?>')" onClick="editRow(this);">
- <?php echo $row_product[$k]["product_name"]; ?>
- </td>
- <td contenteditable="true" onBlur="saveToDatabase(this,'product_qty','<?php echo $row_product[$k]["id"]; ?>')" onClick="editRow(this);">
- <?php echo $row_product[$k]["product_qty"]; ?>
- </td>
- <td>
- <a class="ajax-action-links" onclick="deleteRecord(<?php echo $row_product[$k]["id"]; ?>);">
- Delete
- </a>
- </td>
- </tr>
- <?php
- }
- }
- ?>
- </tbody>
- </table>
Output
