I have a js function passing on a get request to a php file to get db values for the selected record. The get request url reports correct in the js console and the sql is correct.
How do I but I am not sure how to update the dom to refresh the twig template tags. Is there a better way to do this?
Thanks in advance, James
js:
function editCatalogue(id) {
var dataString = 'id='+id;
$.get('catalogue_db.php',
dataString,
function(returnData) {
showDialog();
});
};
php:
if ( (isset($_GET)) && ($_GET['id'] !="") ) {
require_once 'library/twig/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader, array('cache' => 'compilation_cache','debug' => true ));
$template = $twig->loadTemplate('catalogues.html');
$catid = $_GET['id'];
echo $catid;
$sql = "SELECT
catalogues.id,
catalogues.title,
catalogues.keywords,
catalogues.code_bne,
catalogues.description
FROM
catalogues
WHERE
catalogues.id = {catid}
LIMIT 1 ";
foreach ($conn->query($sql) as $row) {
echo $template->render(array(
'title' => $row['title'],
'code_bne' => $row['code_bne'],
'description' => $row['description'],
'keywords' => $row['keywords']
));
}
}