PHP Inline Editing Table using jQuery Ajax
Today, We want to share with you PHP Inline Editing Table using jQuery Ajax.
In this post we will show you Inline Editing using PHP MySQL and jQuery Ajax, hear for Inline Table Editing With jQuery And PHP we will give you demo and example for implement.
In this post, we will learn about PHP MySQL Inline Editing using jQuery Ajax with an example.
Sample database fullnames table columns productname, productdesc and row_order.in this post Inline Edit with PHP, MYSQL & jQuery Ajax
jqphpcrud.sql
CREATE TABLE IF NOT EXISTS `products` ( `id` int(8) NOT NULL, `productname` text NOT NULL, `productdesc` text NOT NULL, `row_order` int(8) NOT NULL ) INSERT INTO `products` (`id`, `productname`, `productdesc`, `row_order`) VALUES (1, 'Mobile', 'Smart Phone', 3), (2, 'Laptop','mini laptop', 4), (3, 'games', 'test', 1), (4, 'Antivirus', 'mini virus', 0), (5, 'redmiii', 'smart table', 2);
dbcontroller.php
PHP database configuration file : dbcontroller.php
conn = $this->connectDB(); } /* load connectDB function*/ function connectDB() { $conn = mysqli_connect($this->host,$this->user,$this->password,$this->database); return $conn; } /* Execute query in php*/ function runQuery($query) { $result = mysqli_query($this->conn,$query); while($row=mysqli_fetch_assoc($result)) { $resultset[] = $row; } if(!empty($resultset)) return $resultset; } /*Total No of count data in php*/ function numRows($query) { $result = mysqli_query($this->conn,$query); $rowcount = mysqli_num_rows($result); return $rowcount; } /* execcute update query*/ function executeUpdate($query) { $result = mysqli_query($this->conn,$query); return $result; } } ?>
saveedit.php
Simple PHP code, updating tables records.
executeUpdate("UPDATE products set " . $_POST["column"] . " = '".$_POST["editval"]."' WHERE id=".$_POST["id"]);; ?>
index.php
Create index.html HMTL file and add simple following css and jquery libraries in it.PHP MySQL Inline Editing using jQuery Ajax
runQuery($sql); ?>PHP MySQL Inline Editing using jQuery Ajax
Product No | productname | productdesc |
---|---|---|
')" onClick="SaveEditData(this);"> | ')" onClick="SaveEditData(this);"> |