I have used an example table from X-Editable, this uses an array in JQuery to populate a drop down options box. This is great but I want to use the database to feed the array.
This below is the code from the X-Editable demo
var jsStringFromPHP = "<?php echo json_encode($r); ?>";
$.mockjax({
url: 'myphppage.php',
response: function (settings) {
this.responseText = jsStringFromPHP;
log(settings, this);
}
});
This is what I've done to get the array from my database
<?php
require 'assets/functions/core/init.php';
$p = db::getInstance()->query('SELECT id as value, name as text FROM information', array());
$r = $p->results();
echo json_encode($r);
?>
How can I incorporate the php array into the jquery and replace the static list?
<pre>tag, and use the result of your php output as a json object via ajax.this.responseText =in the jquery how do I call it?this.responseText = {settings}i guess