I need to use javascript and HTML5 to display the result of the following SQL query in my html page. The SQL query works in SQLite Browser, but I am unsure of how to write the function and corresponding HTML5 code to call the function to display the result of my query. The SQL Query is as follows:
SELECT SUM(Orders.productQty * Products.productPrice) AS grandTotal FROM Orders JOIN Products ON Products.productID = Orders.productID
This returns a numerical result from my SQLite database that is already created, but I do not get how to display the result of the select query on my webpage.
I've tried using the following function to execute the sql statement, but I do not know how to display it using HTML.
function calculateTotalDue() {
db.transaction(function (tx) {
tx.executeSql('SELECT SUM(Orders.productQty * Products.productPrice) AS grandTotal FROM Orders JOIN Products ON Products.productID = Orders.productID', [], []);
});
}
Would someone please show me how to display the result of the query in my html page?