i have problem with a "select" query. In my case, i have a loop (for the first) that scan my Array and for the current value my query must give a result. The code is this below:
for (var key in arrayPlace) {
place = arrayPlace[key].replace(/'/g, '"');
place=$.trim(place);
//Id place
sqls.executeSql("SELECT * FROM luogo_accomodation WHERE nome_luogo LIKE '"+place+"'",[], function(tx,result){
//alert(sqls);
if(result.rows.length==0){
alert("Error.");
}else{
//alert("Found!");
var len = result.rows.length, i;
for (i = 0; i < len; i++){
idLuogo=result.rows.item(i).id_luogo;
}
}
}, null);
//alert(idLuogo);
}
If i print the value of a variables "key" or "place" in the for (the first) i will have as a result the current value of the scan of the Array, but if i print this variables ("key" or "place") inside the query result i will have only last value of my Array.
So if i print the value of variable "idLuogo" after instruction "excetueSql", commented "alert(idLuogo)", i will have the last result of my Array executed in the query.
I can not understand what is the order of execution of the loop and the query.
Can you help me?
Thanks.