What's the write syntax to query an SQLITE database from inside an HTML script? The code below (which btw works perfectly when used in a separate php file) doesn't return anything in the textarea....
Any help would be highly appreciated. Thanks
<p>Patient search:</p>
<textarea id="SearchBoxPt" textarea name="SearchBoxPt" style="height: 30px; resize: none; width: 600px;">
</textarea></p>
<button type="button" onclick="populateField_SearchPt()">Load Pt 1</button>
<script>
function populateField_SearchPt()
{
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('Anagrafica.db');
}
}
$db = new MyDB();
if(!$db)
{
echo $db->lastErrorMsg();
} else
{
echo "Opened database successfully\n\n";
}
$results = $db->query('SELECT name FROM Anagrafica WHERE hospital_ID="1"');
?>
document.getElementById ("SearchBoxPt").value = $results;
}
</script>