Qqlite + HTML5 put the results into variables

0

And I'm doing a query on a Sqlite database and wanted the result to be stored in a javascript variable so I can work with those results in the rest of the code.

I'm doing this:

db.transaction(function(tx) {
var ide = 1;

tx.executeSql('SELECT * FROM tab_users', [ide], function (tx, results) {
var len = results.rows.length, i;

     for (i = 0; i < len; i++) {
       var_name = results.rows.item(i).name;
       var_country = results.rows.item(i).country;
     }

});
});
alert ("Name is " + var_name + " and country is " + var_country);

But this code does not work .. only if I put alert inside loop like this:

for (i = 0; i < len; i++) {
   var_name = results.rows.item(i).name;
   var_country = results.rows.item(i).country;

   alert ("Name is " + var_name + " and country is " + var_country);

}

I need these variables to use at the end of my html code Does anyone have any suggestions on how I can do this?

    
asked by anonymous 10.11.2015 / 13:08

0 answers