Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
- <script>
- function showEdit(editableObj) {
- $(editableObj).css("background","#FFF");
- }
- function saveToDatabase(editableObj,column,id) {
- $(editableObj).css("background","#FFF url(loaderIcon.gif) no-repeat right");
- $.ajax({
- url: "saveedit.php",
- type: "POST",
- data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id,
- success: function(data){
- $(editableObj).css("background","#FDFDFD");
- }
- });
- }
- </script>
- <table class="tabletheme" width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <th scope="col">Name</th>
- </tr>
- <tr>
- <td align="left" valign="top" contenteditable="true">
- <p>John Doe<br>
- 555 West Ave<br>
- Mt Olive, CA 04053
- </p></td>
- </tr>
- </table>
- <?php
- require_once("dbcontroller.php");
- $db_handle = new DBController();
- $result = mysql_query("UPDATE tbl_employee set " . $_POST["column"] . " = '".$_POST["editval"]."' WHERE id=".$_POST["id"]);
- ?>
- <?php
- class DBController {
- private $host = "localhost";
- private $user = "dbuser";
- private $password = "abc12345";
- private $database = "mydatabase";
- function __construct() {
- $conn = $this->connectDB();
- if(!empty($conn)) {
- $this->selectDB($conn);
- }
- }
- function connectDB() {
- $conn = mysql_connect($this->host,$this->user,$this->password);
- return $conn;
- }
- function selectDB($conn) {
- mysql_select_db($this->database,$conn);
- }
- function runQuery($query) {
- $result = mysql_query($query);
- while($row=mysql_fetch_assoc($result)) {
- $resultset[] = $row;
- }
- if(!empty($resultset))
- return $resultset;
- }
- function numRows($query) {
- $result = mysql_query($query);
- $rowcount = mysql_num_rows($result);
- return $rowcount;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement