Professional Documents
Culture Documents
Create Live Editable Table With Jquery
Create Live Editable Table With Jquery
MySQL
Live HTML table edit or inline table edit is a very user friendly feature that enable users to edit
HTML table value directly by clicking on table cells. In our previous HTML table tutorial you have
learned HTML Table Data Export to Excel, CSV and Text using jQuery. In this tutorial you will
learn how to implement live editable HTML table with jQuery and PHP. We will use jQuery
plugin Tabledit that provides AJAX enabled in place editing for HTML table cells.
We will explain and cover this tutorial in easy steps with live demo to create editable HTML
table and save live edit changes into MySQL database table. You can also download source
code of live demo.
As we have covered this tutorial with live demo to implement live editable HTML table with
jQuery and PHP, so the file structure for this example is following.
index.php
custom_table_edit.js
live_edit.php
<?php
include_once("db_connect.php");
$input = filter_input_array(INPUT_POST);
if ($input['action'] == 'edit') {
$update_field='';
if(isset($input['name'])) {
$update_field.= "name='".$input['name']."'";
} else if(isset($input['gender'])) {
$update_field.= "gender='".$input['gender']."'";
} else if(isset($input['address'])) {
$update_field.= "address='".$input['address']."'";
} else if(isset($input['age'])) {
$update_field.= "age='".$input['age']."'";
} else if(isset($input['designation'])) {
$update_field.= "designation='".$input['designation']."'";
}
if($update_field && $input['id']) {
$sql_query = "UPDATE developers SET $update_field WHERE id='" . $input['id'] . "'";
mysqli_query($conn, $sql_query) or die("database error:". mysqli_error($conn));
}
}
?>
You can view the live demo from the Demo link and can download the script from the
Download link below.
From: https://www.phpzag.com/create-live-editable-table-with-jquery-php-and-mysql/
jQuery Ajax Live Editable Table Records
using PHP MySQLi
By admin MySQL, PHP, Technology 0 Comments
Today, We want to share with you jQuery Ajax Live Editable Table Records using PHP MySQLi.
In this post we will show you jquery inline edit table row, hear for Inline Editing using PHP MySQL
and jQuery Ajax we will give you demo and example for implement.
In this post, we will learn about Add, Edit And Delete Records Using jQuery, Ajax, PHP And MySQL with
an example.
jQuery Ajax Live Editable Table Records using PHP
MySQLi
There are the Following The simple About jQuery Ajax Live Editable Table Records using PHP
MySQLi Full Information With Example and source code.
index.php
1. <table id="data_table" class="infinity table table-striped">
2. <thead>
3. <tr>
4. <th>Id</th>
5. <th>StudentName</th>
6. <th>Student Gender</th>
7. <th>Student Age</th>
8. <th>Main Subject</th>
9. <th>Student Address</th>
10. </tr>
11. </thead>
12. <tbody>
13. <?php
14. $live_stud_query = "SELECT id, name, gender, student_address, mainsubject, age FROM
students LIMIT 10";
15. $resultset = mysqli_query($conn, $live_stud_query) or die("database error:".
mysqli_error($conn));
16. while( $student = mysqli_fetch_assoc($resultset) ) {
17. ?>
18. <tr id="<?php echo $student ['id']; ?>">
19. <td><?php echo $student ['id']; ?></td>
20. <td><?php echo $student ['name']; ?></td>
21. <td><?php echo $student ['gender']; ?></td>
22. <td><?php echo $student ['age']; ?></td>
23. <td><?php echo $student ['mainsubject']; ?></td>
24. <td><?php echo $student ['student_address']; ?></td>
25. </tr>
26. <?php } ?>
27. </tbody>
28. </table>
Step 4: Create HTML Table Editable
live_edit.php
Last step in live_edit.php, I shall manage functionality to all the records update edit changes into
simple query To Save Live HTML Table Edit into MySQL Database.
1. <?php
2. include_once("db_connect.php");
3. $frm_field = filter_frm_field_array(INPUT_POST);
4. if ($frm_field['action'] == 'edit') {
5. $student_update='';
6. if(isset($frm_field['name'])) {
7. $student_update.= "name='".$frm_field['name']."'";
8. } else if(isset($frm_field['gender'])) {
9. $student_update.= "gender='".$frm_field['gender']."'";
10. } else if(isset($frm_field['student_address'])) {
11. $student_update.= "student_address='".$frm_field['student_address']."'";
12. } else if(isset($frm_field['age'])) {
13. $student_update.= "age='".$frm_field['age']."'";
14. } else if(isset($frm_field['mainsubject'])) {
15. $student_update.= "mainsubject='".$frm_field['mainsubject']."'";
16. }
17. if($student_update && $frm_field['id']) {
18. $live_stud_query = "UPDATE students SET $student_update WHERE id='" . $frm_field['id']
. "'";
19. mysqli_query($conn, $live_stud_query) or die("database error:". mysqli_error($conn));
20. }
21. }
22. ?>
jQuery 15 Powerful Tips and Tricks for Developers and Web Designer
Read :
Technology
Google Adsense
Articles
Summary
From: https://infinityknow.com/jquery-ajax-live-editable-table-records-using-php-mysqli/