Advertisements
Offline
westdh
Posts: 1
Joined: Fri Nov 11, 2011 1:49 am
Location: Eagle Point Oregon
<script type="text/javascript">
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
var msg;
db.transaction(function (tx) {
tx.executeSql('DROP TABLE IF EXISTS LOGS (id unique, log)');

tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (3, "test01")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (4, "test02")');

msg = '<p>Log message created and row inserted.</p>';
document.querySelector('#status').innerHTML = msg;
});

db.transaction(function (tx) {
tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
var len = results.rows.length, i;
msg = "<p>Found rows: " + len + "</p>";
document.querySelector('#status').innerHTML += msg;
for (i = 0; i < len; i++){
msg = "<p><b>" + results.rows.item(i).log + "</b></p>";
document.querySelector('#status').innerHTML += msg;
}
}, null);
});
</script>
</head>
<body onload="onBodyLoad()">

<div id="status" name="status">Status Message</div>

</body>
========================================================

this is the results no manner how many rows I add?
------------------------------------------------------
Log message created and row inserted

Found rows: 2

foobar

logging