prepare("SELECT * FROM media WHERE id = :id"); $query->bindValue(':id', $id); $result = $query->execute(); if ($result) { // record exists $update_query = $db->prepare("INSERT INTO media_edls (media_id, edl_name, edl_contents) VALUES (:media_id, :edl_name, :edl_contents)"); $update_query->bindValue(':media_id', $_REQUEST['id']); $update_query->bindValue(':edl_name', $_REQUEST['edl_name']); $update_query->bindValue(':edl_contents', $_REQUEST['edl_contents']); $update_result = $update_query->execute(); if ($update_result) { $query = $db->prepare("SELECT * FROM media m JOIN media_edls em ON m.id = me.media_id WHERE m.id = :id"); $query->bindValue(':id', $id); $final_result = $query->execute(); if ($final_result) { echo(json_encode($final_result->fetchArray(SQLITE3_ASSOC))); } } } } ?>