Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <div id="status" name="status">Status Message</div>
  2.  
  3. var db = openDatabase('mydb', '1.0', 'Test DB', 4 * 1024 * 1024);
  4. var msg;
  5. db.transaction(function (tx) {
  6. tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log Text,log1 Text)');
  7. tx.executeSql('INSERT INTO LOGS (id, log,log1) VALUES (1, "foobar","sa")');
  8. tx.executeSql('INSERT INTO LOGS (id, log,log1) VALUES (2, "logmsg","da")');
  9. msg = '<p>Log message created and row inserted.</p>';
  10. document.querySelector('#status').innerHTML = msg;
  11. });
  12.  
  13. db.transaction(function (tx) {
  14. tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
  15. var len = results.rows.length,
  16. i;
  17. msg = "<p>Found rows: " + len + "</p>";
  18. document.querySelector('#status').innerHTML += msg;
  19.  
  20. for (i = 0; i < len; i++) {
  21. msg = "<p><b>" + results.rows.item(i).log + "</b></p>";
  22. document.querySelector('#status').innerHTML += msg;
  23. var book = results.rows.item(i);
  24. console.log(book);
  25.  
  26. alert(book.log1);
  27.  
  28. }
  29.  
  30. }, null);
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement