用html编辑1.Sqlite数据库设计:自己建立一个表,列出表信息。 2.后端API开发,列出开发步骤。 前端js开发页面:查询显示页面,修改页面,删除页面等。

时间: 2024-03-13 16:46:21 浏览: 20
好的,我来为你演示一下用HTML编辑页面的过程。 1. Sqlite数据库设计页面: ```html <!DOCTYPE html> <html> <head> <title>Sqlite数据库设计</title> </head> <body> <h1>Sqlite数据库设计</h1> <form> <label for="tableName">表名:</label> <input type="text" id="tableName" name="tableName"><br><br> <label for="id">id:</label> <input type="text" id="id" name="id"><br><br> <label for="name">name:</label> <input type="text" id="name" name="name"><br><br> <label for="age">age:</label> <input type="text" id="age" name="age"><br><br> <label for="email">email:</label> <input type="text" id="email" name="email"><br><br> <input type="button" value="提交" onclick="submitForm()"> </form> <script> function submitForm() { const tableName = document.getElementById("tableName").value; const id = document.getElementById("id").value; const name = document.getElementById("name").value; const age = document.getElementById("age").value; const email = document.getElementById("email").value; const sql = `CREATE TABLE ${tableName} ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age TEXT, email TEXT );`; alert(`您输入的SQL语句为:\n\n${sql}`); } </script> </body> </html> ``` 2. 后端API开发页面: ```html <!DOCTYPE html> <html> <head> <title>后端API开发</title> </head> <body> <h1>后端API开发</h1> <form> <label for="apiUrl">API URL:</label> <input type="text" id="apiUrl" name="apiUrl"><br><br> <label for="apiMethod">请求方式:</label> <select id="apiMethod" name="apiMethod"> <option value="GET">GET</option> <option value="POST">POST</option> <option value="PUT">PUT</option> <option value="DELETE">DELETE</option> </select><br><br> <label for="apiHandler">API处理函数:</label> <textarea id="apiHandler" name="apiHandler"></textarea><br><br> <label for="dbUrl">数据库URL:</label> <input type="text" id="dbUrl" name="dbUrl"><br><br> <label for="dbUser">数据库用户名:</label> <input type="text" id="dbUser" name="dbUser"><br><br> <label for="dbPassword">数据库密码:</label> <input type="password" id="dbPassword" name="dbPassword"><br><br> <input type="button" value="提交" onclick="submitForm()"> </form> <script> function submitForm() { const apiUrl = document.getElementById("apiUrl").value; const apiMethod = document.getElementById("apiMethod").value; const apiHandler = document.getElementById("apiHandler").value; const dbUrl = document.getElementById("dbUrl").value; const dbUser = document.getElementById("dbUser").value; const dbPassword = document.getElementById("dbPassword").value; const api = ` API URL: ${apiUrl} 请求方式: ${apiMethod} API处理函数: ${apiHandler} 数据库URL: ${dbUrl} 数据库用户名: ${dbUser} 数据库密码: ${dbPassword}`; alert(`您输入的API信息为:\n\n${api}`); } </script> </body> </html> ``` 3. 前端JS开发页面: ```html <!DOCTYPE html> <html> <head> <title>前端JS开发</title> </head> <body> <h1>前端JS开发</h1> <h2>查询显示页面</h2> <table> <thead> <tr> <th>id</th> <th>name</th> <th>age</th> <th>email</th> </tr> </thead> <tbody id="tableBody"></tbody> </table> <button onclick="loadData()">查询</button> <h2>修改页面</h2> <form> <label for="modifyId">id:</label> <input type="text" id="modifyId" name="modifyId"><br><br> <label for="modifyName">name:</label> <input type="text" id="modifyName" name="modifyName"><br><br> <label for="modifyAge">age:</label> <input type="text" id="modifyAge" name="modifyAge"><br><br> <label for="modifyEmail">email:</label> <input type="text" id="modifyEmail" name="modifyEmail"><br><br> <input type="button" value="提交" onclick="modifyData()"> </form> <h2>删除页面</h2> <form> <label for="deleteId">id:</label> <input type="text" id="deleteId" name="deleteId"><br><br> <input type="button" value="提交" onclick="deleteData()"> </form> <script> const apiUrl = "http://localhost:3000/users"; function loadData() { fetch(apiUrl) .then(response => response.json()) .then(data => { const tableBody = document.getElementById("tableBody"); tableBody.innerHTML = ""; data.forEach(user => { const tr = document.createElement("tr"); const tdId = document.createElement("td"); const tdName = document.createElement("td"); const tdAge = document.createElement("td"); const tdEmail = document.createElement("td"); tdId.innerText = user.id; tdName.innerText = user.name; tdAge.innerText = user.age; tdEmail.innerText = user.email; tr.appendChild(tdId); tr.appendChild(tdName); tr.appendChild(tdAge); tr.appendChild(tdEmail); tableBody.appendChild(tr); }); }) .catch(error => console.error(error)); } function modifyData() { const id = document.getElementById("modifyId").value; const name = document.getElementById("modifyName").value; const age = document.getElementById("modifyAge").value; const email = document.getElementById("modifyEmail").value; const data = { name, age, email }; fetch(`${apiUrl}/${id}`, { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log(data); alert(`更新成功!`); }) .catch(error => console.error(error)); } function deleteData() { const id = document.getElementById("deleteId").value; fetch(`${apiUrl}/${id}`, { method: "DELETE" }) .then(response => response.json()) .then(data => { console.log(data); alert(`删除成功!`); }) .catch(error => console.error(error)); } </script> </body> </html> ``` 以上三个页面分别对应了你的三个问题,其中第一个页面用来输入SQL语句创建表格,第二个页面用来输入API信息,第三个页面用来展示数据并提供修改和删除功能。注意,这里只是一个简单的示例,实际开发中还需要考虑很多其他因素。

相关推荐

最新推荐

recommend-type

c++获取sqlite3数据库表中所有字段的方法小结

本文给大家分享c++获取sqlite3数据库表中所有字段的三种常用方法,本文针对每一种方法给大家详细介绍,需要的的朋友通过本文一起学习吧
recommend-type

Python实现将sqlite数据库导出转成Excel(xls)表的方法

主要介绍了Python实现将sqlite数据库导出转成Excel(xls)表的方法,结合实例形式分析了Python针对sqlite数据库的连接、读取及使用写操作包(xlwt)生成Excel表的相关实现技巧,需要的朋友可以参考下
recommend-type

js+html5操作sqlite数据库的方法

主要介绍了js+html5操作sqlite数据库的方法,以完整实例形式分析了JavaScript封装的html5操作SQLite数据库类,并分析了具体使用技巧,需要的朋友可以参考下
recommend-type

SQLite教程(十):内存数据库和临时数据库

主要介绍了SQLite教程(十):内存数据库和临时数据库,本文讲解了它们的创建方法和相关知识,需要的朋友可以参考下
recommend-type

力控与sqlite数据库交换数据配置.doc

力控与SQLite数据库交换数据教程(2021.3.3)。自己编写测试,免费与众网友交流共享
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

HSV转为RGB的计算公式

HSV (Hue, Saturation, Value) 和 RGB (Red, Green, Blue) 是两种表示颜色的方式。下面是将 HSV 转换为 RGB 的计算公式: 1. 将 HSV 中的 S 和 V 值除以 100,得到范围在 0~1 之间的值。 2. 计算色相 H 在 RGB 中的值。如果 H 的范围在 0~60 或者 300~360 之间,则 R = V,G = (H/60)×V,B = 0。如果 H 的范围在 60~120 之间,则 R = ((120-H)/60)×V,G = V,B = 0。如果 H 的范围在 120~180 之间,则 R = 0,G = V,B =
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。