It is necessary that the login and password are presented in the form of a variable. How to write the correct request?

<html> <body> <script> db = openDatabase("DATAPASS", "0.1", "LOGIN DATA", 200000); if (!db) { alert("Failed"); } db.transaction(function (trans) { trans.executeSql("CREATE TABLE IF NOT EXISTS pass (id INTEGER PRIMARY KEY ASC, login TEXT, password TEXT)"); trans.executeSql("INSERT INTO pass IF NOT EXISTS (login, password) values(?,?)", ["admin", "admin"]) trans.executeSql("INSERT INTO pass(login, password) values(?,?)", ["a123dmin1", "adm123in1"]) trans.executeSql("DELETE FROM pass WHERE login = ?", ["admin"]) }) </script> </body> </html> 

    1 answer 1

    When SELECT'e need another function in which the results come. This code returns all login => password pairs:

      db = openDatabase("DATAPASS", "0.1", "LOGIN DATA", 200000); db.transaction(function(trans) { trans.executeSql('SELECT login, password FROM pass', [], function(trans, result) { var len = result.rows.length, i; for (i = 0; i < len; i++) { console.log(result.rows.item(i).login + " => " + result.rows.item(i).password); } }, function(trans, e) { console.log("Error"); }); });