var db = openDatabase ('mydb', '1.0', 'Test DB', 2*1024*1024);
db.transaction(function (tx)
{
tx.executeSql(' CREATE TABLE IF NOT EXISTS EMPLOYEE (id unique, name)');
});
var db = openDatabase ('mydb', '1.0', 'Test DB', 2*1024*1024);
db.transaction(function (tx)
{
tx.executeSql ('CREATE TABLE IF NOT EXIXTS EMPLOYEE (id unique, name)');
tx.executeSql ('INSERT INTO EMPLOYEE (id, name) VALUES (1, “Rahul”)');
tx.executeSql ('INSERT INTO EMPLOYEE (id, name) VALUES (2, “Prajakta”)');
tx.executeSql ('INSERT INTO EMPLOYEE (id, name) VALUES (1, “Sakshi”)');
});
var db = openDatabase ('mydb', '1.0', 'Test DB', 2*1024*1024);
db.transaction(function (tx)
{
tx.executeSql ('CREATE TABLE IF NOT EXIXTS EMPLOYEE (id unique, name)');
tx.executeSql ('INSERT INTO EMPLOYEE (id, name) VALUES (?,'?'), [e_id, e_log];
});
var db = openDatabase ('mydb', '1.0', 'Test DB', 2*1024*1024);
db.transaction(function (tx)
{
tx.executeSql(' CREATE TABLE IF NOT EXIXTS EMPLOYEE (id unique, name)');
tx.executeSql ('INSERT INTO EMPLOYEE (id, name) VALUES (1, “Rahul”)');
tx.executeSql ('INSERT INTO EMPLOYEE (id, name) VALUES (2, “Prajakta”)');
tx.executeSql ('INSERT INTO EMPLOYEE (id, name) VALUES (1, “Sakshi”)');
});
db.transaction(function (tx)
{
tx.executeSql('SELECT * FROM EMPLOYEE', [], function (tx, results)
{
var len = results.rows.length, i;
msg = "<p>Number of rows found: " + len + "</p>";
document.querySelector('#status').innerHTML += msg;
for (i = 0; i < len; i++)
{
alert(results.rows.item(i).log );
}
}, null);
});
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
var msg;
db.transaction(function (tx)
{
tx.executeSql('CREATE TABLE IF NOT EXISTS SUBJECTS (id unique, log)');
tx.executeSql('INSERT INTO SUBJECTS (id, log) VALUES (1, "Java")');
tx.executeSql('INSERT INTO SUBJECTS (id, log) VALUES (2, "C Programming")');
tx.executeSql('INSERT INTO SUBJECTS (id, log) VALUES (3, "HTML5")');
msg = '<p>Log message created and row inserted.</p>';
document.querySelector('#status').innerHTML = msg;
});
db.transaction(function (tx)
{
tx.executeSql('SELECT * FROM SUBJECTS', [], function (tx, results)
{
var len = results.rows.length, i;
msg = "<p>Number of rows found: " + 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>
<div id="status" name="status">Status Message</div>
</body>
</html>