ersaurabh101 Posted March 12, 2017 Share Posted March 12, 2017 I have only 1 record ( this is - username,password saved in my table) I need to select the username and count the no. of rows but both of the things not working, copying my code below SELECT STATEMENT: returning me [object][object] var selectStatement = "select username FROM loggedinuser"; var result; function getusername() { db.transaction(function (tx) { tx.executeSql(selectStatement,[],querySuccess); }); function querySuccess(tx, results) { for(var i=0; i<results.rows.length; i++) { var row = results.rows.item; result = { id: row['username']}; alert(result); } } } COUNT STATEMENT: below record is giving me result "1" at alert(len); var countStatement = "select COUNT(*) from loggedinuser"; var db = openDatabase("AddressBook", "1.0", "Address Book", 200000); // Open SQLite Database var user,password; function countRecord(tx) { db.transaction(function (tx) { tx.executeSql('SELECT count(*) FROM loggedinuser', [], querySuccess, errorCB); }); } function querySuccess(tx, results) { var len = results.rows.length; alert(len); } function errorCB(err) { alert("Error processing SQL: "+err.code); } countRecord(); Please help.. Quote Link to comment https://forums.phpfreaks.com/topic/303437-sqlite-statement-not-working/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.