Sqlite Database localstorge

<!DOCTYPE HTML>
<html>

<head>

var db = openDatabase(‘mydb’, ‘1.0’, ‘Test DB’, 2 * 1024 * 1024);
var msg;

db.transaction(function (tx) {
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”)’);
msg = ‘

Log message created and row inserted.

‘;
document.querySelector(‘#status’).innerHTML = msg;
});

db.transaction(function (tx) {
tx.executeSql(‘SELECT * FROM LOGS’, [], function (tx, results) {
var len = results.rows.length, i;
msg = ”

Found rows: ” + len + ”

“;
document.querySelector(‘#status’).innerHTML += msg;

for (i = 0; i ” + results.rows.item(i).log + “

“;
document.querySelector(‘#status’).innerHTML += msg;
}
}, null);
});

</head>

<body>

Status Message

</body>

</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s