<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
//
// sessionStorage.man = 'hehe';
// console.log(sessionStorage.man);
// localStorage.asd = 'haaaaaahaaaaaaa';
// console.log(localStorage.asd);
// var a = '{"name":"小明","sex":"男"}';
// var c = JSON.parse(a);
// localStorage.fff = c;
// console.log(localStorage.fff);
// console.log(c.name , c.sex);
//建立数据库
var aa = openDatabase('F08','','','3000');
//建立表格
aa.transaction(function(tx){
tx.executeSql('create table if not exists t_f08(t_number int,t_name varchar(50))',
[],
function(r){
console.log(r);
},function(e){
console.log(e);
});
});
//aa.transaction(function(tx){
// tx.executeSql('CREATE TABLE if not exists t_f08(t_number INT, t_name VARCHAR(50))');
//});
//添加数据
aa.transaction(function(tx){
tx.executeSql('insert into if not exists t_f08 values(1,"小明")',
[],
function(r){
console.log(r);
},function(e){
console.log(e);
});
});
//aa.transaction(function(tx){
// tx.executeSql('insert into if not exists t_f08 values(1,"小明")');
//});
//添加数据
aa.transaction(function(tx){
tx.executeSql('insert into if not exists t_f08 values(2,"中明")',
[],
function(r){
console.log(r);
},function(e){
console.log(e);
});
});
// aa.transaction(function(tx){
// tx.executeSql('insert into if not exists t_f08 values(2,"中明")');
//});
//var bb = openDatabase('FFFF','','','3000');
// bb.transaction(function(tx){
// tx.executeSql(create table if not exists t_fff());
// });
//查询数据
aa.transaction(function(tx){
tx.executeSql('select * from t_f08',
[],
function(t,res){
for(var i=0;i<res.rows.length;i++){
console.log(res.rows.item(i).t_number);
console.log(res.rows.item(i).t_name);
}
},function(t,e){
console.log(e);
});
});
</script>
</body>
</html>