I am using sqlite database in my project.
My table structure will be almost like this
id cid values 1 1 value1 2 1 value2 3 1 value3 4 1 value4 5 2 value1 6 2 value2 7 3 value1 8 3 value2 9 3 value3
so I want all the values of the same cid, how do I encode?
My request:
tx.executeSql("SELECT cid,value FROM table where cid="+cid_value, [], querySuccess, errorCB,cid_value);
because when I tried this,
var details = results.rows.length; console.log("db test value:"+results.rows.item(cid_value).value); for (var i=cid_value; i<details; i++) { cidinstance=results.rows.item(i).cid; var valueinstance=results.rows.item(i).value; document.getElementById("s"+i+"cause").innerHTML=valueinstance; console.log("cid= "+cidinstance + "valueinstance= "+valueinstance); }
then when i = cid_value (cid_value = 1) targeting cid = 1, where we have four values, I get only 3 values . but if I put i = 0 then i get 4 values
when i = cid_value (cid_value = 2) targeting cid = 2, I get the following
01-01 05:45:38.687: I/Web Console(2425): JSCallback: Message from Server: SQLitePluginTransaction.queryCompleteCallback('1104538538488000','1104538538491000', [{"value":"value1","cid":"2"},{"value":"value22","id":"6","cid":"2"}]); at file:
The problem is that I get values ββwhen I receive a message from the server as JS Callback. not out of for loop
Please suggest me ways to solve the problem! .Guide me to find a way out.