บันทึกการ Select ข้อมูลจาก SQLite
//- - - Loop แบบ Each
function queryDB(tx){
dbShell.transaction(function(tx){
tx.executeSql("select id, title, body, updated from notes order by updated desc",[],
function(tx, results){
if (results.rows.length>0){
var s = "";
$.each(results.rows,function(index){
var row = results.rows.item(index);
s += "<li><a href='edit.html?id="+row.id + "'>"+row.title + "</a></li>";
}
$("#noteTitleList").html(s);
$("#noteTitleList").listview("refresh");
}
}
}
}
//- - - Loop แบบ For
function queryDB(tx){
dbShell.transaction(function(tx){
tx.executeSql("select id, title, body, updated from notes order by updated desc",[],
function(tx, results){
if (results.rows.length>0){
var s = "";
for(var i=0; i<results.rows.length; i++){
var row = results.rows.item(i);
s += "<li><a href='edit.html?id="+row.id + "'>"+row.title + "</a></li>";
}
$("#noteTitleList").html(s);
$("#noteTitleList").listview("refresh");
}
}
}
}