Hello,
I am trying to make a login system with WebSQL. The sign up works. However, I want to make a function to see if I can see the usernames in an array. This is my code (I have a column for name and password):
var db = openDatabase('personDB', '1.0', 'the data of people', 2*1024*1024);
var exists=[];
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM people', [], function (tx, results) {
var len = results.rows.length, i;
for (i = 0; i < len; i++) {
exists.push(results.rows.item(i).username);
}
});
});
return exists;
When I try it in a snap block, it doesn't report anything. Well, it reports something, but it reports a blank and empty array. However, when I try to do it in console, it works perfectly. Is there something I am doing wrong?
I'd appreciate it if I could get a quick response, because this is part of a project that is due tomorrow.