Could someone please assist me with retrieving values from a database? Here is my code:
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
console.log("Run1");
var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
});
db.transaction(function (tx){
for (var index = 1; index < 10; index++){
tx.executeSql('INSERT INTO LOGS (id,log) VALUES ('+index+', '+index+')');
}
});
}
</script>
A table has been created and 10 rows have been inserted. However, I am having trouble retrieving and displaying the values.
<input id="DBlist" type="submit" onClick='showList()' data-theme="b" value="Saved values" data-mini="false">
function showList()
{
var db = window.sqlitePlugin.openDatabase({name: "MYDB2"});
db.transaction(function(tx) {
tx.executeSql("select * from LOGS;", [], function(tx, res) {
// How can I display all the rows in console.log()?
});
});
}
Any suggestions or advice would be greatly appreciated...