基本上,我拥有的是一个用户登录的系统,他们会被带到一个页面,显示他们正在从事的项目。项目是通过组名称、截止日期、描述和关联的类来定义的。就目前而言,代码可以让用户登录。将用户带到带有表的页面,他们可以在其中输入数据,创建一个插入了所有数据的新行,但数据永远不会添加到数据库中。我不太确定如何继续前进;数据库设计和存储用户输入数据库的变量,以便用户下次登录时,他们能够看到已添加到表中的所有项目。
数据库表:
用户:ID(int)(主键)(AI)、用户名(VARCHAR)、密码(VARCHAR)
组:ID(Int)(主键)(AI),名称(VARCHAR)
到期日:ID(INT)(主键)(AI),到期日(DATE)
描述:ID(int)(主键(AI),名称(varchar)
类:ID(int)(主键)(AI),名称(varchar)
index.php
<?php
session_start();
?>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>index.php</title>
<link rel="stylesheet" type="text/css" href="index.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<h1>OneProject</h1>
<a href="index.php">Home</a>-<a href="register.php">Register</a>-<a href="login.php">Login</a>-<a href="logout.php">Logout</a><hr />
<?php
if (isset($_SESSION['name'])) {
?>
<TABLE BORDER="4" WIDTH="30%" CELLPADDING="4" CELLSPACING="3">
<tr>
<th colspan="6"><h2>Projects</h2></th>
</tr>
<tr>
<th>group</th>
<th>class</th>
<th>due date</th>
<th>description</th>
<th></th>
</tr>
<tr>
<td><input type="text" id="group" /></td>
<td><input type="text" id="class" /></td>
<td><input type="date" id="duedate" /></td>
<td><input type ="text" id="description" /></td>
<th><image src="green-plus-sign-hi-png.png" alt="" height="10" width="10" id="add"></th>
</tr>
</table>
<?php
} else {
header('Location: login.php');
}
?>
</body>
</html>
index.js
$(document).ready(function() {
$("#add").click(function() {
var group=document.getElementById("group");
var myClass= document.getElementById("class");
var duedate=document.getElementById("duedate");
var descrip=document.getElementById("description");
$("table tr:last").after("<tr><td>"+group.value+"</td><td>"+myClass.value+"</td><td id='late'>"+duedate.value+"</td><td>"+descrip.value+"</td><td><image src='1659484_orig.png' id='delete' height='10' width= '10'>");
});
$("table").on("click","#delete", function(){
$("#delete").closest("tr").remove();
});
});
最佳答案
在我看来,你需要在这个领域多学一点。检查 tptcat 链接。
但是,如果您想通过示例进行学习,网络上有很多很好的教程,请查看示例
- 这个http://tutbuzz.com/your-own-todo-list-using-php-mysql-jquery
- 或http://tutorialzine.com/2010/03/ajax-todo-list-jquery-php-mysql-css/
- 或https://tutsplus.com/tutorial/how-to-code-a-fun-to-do-list-with-php-and-ajax/
但对我来说,而不是尝试将 PHP、MYSQL、CSS、HTML 和 jquery 混合在一起。
首先,尝试只学习 PHP 和 MYSQL。
关于php - 使用 php、mysql 和 jquery 创建包含用户登录名和用户特定列表的待办事项列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20510354/