带有SQL数据库的HTML5 [英] HTML5 with SQL Database
问题描述
我正在使用HTML5制作这个SQL数据库代码在这里
<!DOCTYPE HTML>
< html>
< ; head>
< script>
var db = openDatabase('mydb','1.0','Test DB',2 * 1024 * 1024);
var msg;
db.transaction(function(tx){
tx.executeSql('CREATE TABLE IF NOT NOT EXISTS LOGS(id unique,log )');
tx.executeSql('INSERT INTO LOGS(id,log)VALUES(1,foobar)');
tx.executeSql('INSERT INTO LOGS(id,log)VALUES(2,logmsg)');
msg ='
创建日志消息并插入行。
I am making this SQL database using HTML5 the code is here
<!DOCTYPE HTML>
<html>
<head>
<script>
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
var msg;
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")');
msg = '
Log message created and row inserted.
找到行:+ len +
Found rows: " + len + "
+ results.rows.item(i).log +
< / body>
< / html>
此代码将输入的信息添加到我的数据库中
tx.executeSql('INSERT INTO LOGS( id,log)VALUES(1,foobar)');
tx.executeSql('INSERT INTO LOGS(id,log)VALUES(2,logmsg)');
但是,我希望我的用户在文本框中输入他们的信息,然后保存到我的数据库中
请帮助
谢谢
</body>
</html>
This codes adds the information in enter to my databse
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")');
But instead of this, i want my user to enter their information in a textbox which then saves to my database
Please help
Thanks
推荐答案
1。永远不要在前端使用数据库命令(即HTML,即使它是HTML5)。
2.你应该使用一个好的后端这样的ASP。网络或PHP。
3.如果您没有/(关心)上述内容,请在正文中使用输入标签,以便控制用户可以将文本写入。 Al输入标签也应该包含在
aform标签中。
4.你的脚本应该包含在一个功能中,因为这不是一个功能它
只是在页面加载时运行(这不是你想要的)。
5.按钮你使用的应该调用你附上命令的函数。
要实现所有上述谷歌html控件, html表单标签,javascript函数,按钮命令。
这在单个解决方案伙伴中回答太多工作但是我已经给了你线索。由你来收集所有必要的知识。
1. Never use Database Commands on the front-end (that is HTML, even if it is HTML5).
2. You should use a good back-end such ASP.Net or PHP.
3. In case you don't have/(care about) the aforementioned, use "input" tags in the body so there are controls the user can write the text into. Al input tags should be enclosed in
a "form" tag also.
4. Your script should be enclosed into a fuction, cause when it is not within a function it
just runs when the page loads (which is not what you want).
5. The button you use should call the function in which you enclosed your commands.
To achieve all of the aforementioned google "html controls", "html form tag", "javascript function", "button command".
This would be too much work to answer in a single solution buddy but I've given you a clue. it's up to you to gather all necessary knowledge.
这篇关于带有SQL数据库的HTML5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!