I am building a local database with this :
var db = openDatabase('LIST','1.0','database', 2*1024*1024);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS entry (ID INTEGER PRIMARY KEY ASC, first TEXT, last TEXT, email TEXT, phone TEXT, contest TEXT, added_on DATETIME)');
});
db.transaction(function(tx){
tx.executeSql('INSERT INTO entry (first, last, email, phone, contest, added_on) VALUES (?,?,?,?,?,?)',
[vFirst, vLast, vEmail, vPhone, vContest, addedOn]);
});
How would I populate a div with count of total rows in the database? I guess I would use something like SELECT COUNT(*) FROM entry .. but I am unclear on how to write this or print the output on the page.
If I was using local storage I see I could do something as simple as var length = window.localStorage.length; but I can not figure out how to do something similar with SQL.
If you want to count all rows from
entrytable, thenSELECT COUNT(*) FROM entryIf you want to know count of rows in database, then
UNIONqueries from different tables and sum usingSUM()EDIT: