Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTML5:websql ejemplo básico
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web SQL</title>
<script type="text/javascript">
function almacenar()
{
var db=openDatabase('Mibbdd','1.0','mi base de datos', 2*1024*1024);
db.transaction(function(tx)
{
tx.executeSql('CREATE TABLE IF NOT EXISTS tabla(nombre,apellido)');
tx.executeSql('INSERT INTO tabla (nombre,apellido) VALUES ("Gustavo","Lacoste")');
});
alert("BBDD inicializada");
db.transaction(function(tx)
{
tx.executeSql('SELECT * FROM tabla',[],function(tx,results)
{
var len=results.rows.length;
for (i=0;i<len;i++)
{
alert(results.rows.item(i).nombre+" "+results.rows.item(i).apellido);
}
});
});
}
</script>
</head>
<body onload="almacenar();">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.