I am using X-Editable-Bootstrap to do some inline editing. Everything works but it's not updating the DB so I am wondering if I am doing something wrong.
Here's my post.php
require_once("config.php");
$pk = $_POST['pk'];
$name = $_POST['name'];
$value = $_POST['value'];
if(!empty($value)) {
try {
$dbh = new PDO('mysql:host='. DB_HOST .';dbname='. DB_NAME, DB_USER, DB_PASS);
$sth = $dbh->prepare('UPDATE qa_tbl SET ?=? WHERE id = ?');
$sth->execute(array($name,$value,$pk));
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
print_r($_POST);
} else {
header('HTTP 400 Bad Request', true, 400);
echo "This field is required!";
}
Here's the response body from FireFox debugging:
Array
(
[name] => Question
[value] => Yes
[pk] => 2
)
JavaScript:
$(function(){
$.fn.editable.defaults.mode = 'inline';
$('.editcontent').editable({
url: 'post.php',
title: 'Modify Entry'
});
});