mysql access by html5

<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 h (id unique,log)’);
tx.executeSql(‘INSERT INTO h(id,log) VALUES(3,”hello”)’);
msg='<h1>OK value is added</h1>’;
document.querySelector(‘#status’).innerHTML= msg;
});
db.transaction(function(tx){
tx.executeSql(‘SELECT * FROM h’,[],function(tx,result){
var len=result.rows.length, i;
msg=”<p>Fount data”+ len +”</p>”;
document.querySelector(‘#status’).innerHTML += msg;
for(i=0;i<len;i++){
msg=”<p><b>”+ result.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>

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