[英]Building task list with PHP and MySQL
I have basic knowledge in PHP and MySQL. 我有PHP和MySQL的基本知识。
Im trying to build an application for employees working with a weekly task list. 我正在尝试为每周任务列表的员工构建应用程序。 I have a working application for other duties with user login etc. so I need this "task list application" to be integrated. 我有一个可以处理用户登录等其他职责的应用程序,因此需要集成此“任务列表应用程序”。
I have an idea how to do this in a bad way, so I need your help to be "pushed into right direction" =) 我有个不好的办法,所以我需要您的帮助才能“正确地推动” =)
Every task list is stored for statistics etc. 存储每个任务列表以进行统计等。
Right know my table kind of looks like this (real table contains 50+ tasks): 知道我的表看起来像这样(实际表包含50多个任务):
ID || userID || task1 || task1description || task2 || task2description || timestamp
Right now I have set "Standard value" in the description fields, for describing the task. 现在,我已经在描述字段中设置了“标准值”,用于描述任务。 The reason for this is that I want to echo the full task list in a while loop. 原因是我想在while循环中回显整个任务列表。
I suppose there is a much better way to do this? 我想有更好的方法吗? Above solution works but my table gets very large because every row contains the descriptions. 上面的解决方案有效,但是我的表变得很大,因为每一行都包含描述。 Another solution is to manually write descriptions in HTML, but I want everything to be dynamic. 另一个解决方案是用HTML手动编写描述,但是我希望一切都是动态的。
Plz help! 请帮忙! =) =)
Have multiple tables and use foreign keys. 有多个表并使用外键。 You should normalize your database. 您应该规范化数据库。
For instance have a table users
that contains a user_id
, username
, pherhaps password
etc. 例如,有一个表users
,其中包含一个user_id
, username
,pherhaps password
等。
and have a separate table that tasks
which has columns task_id
, task_name
, and task_description
并且有一个单独的表tasks
具有列task_id
, task_name
和task_description
Then have a table to link them together user_tasks
which has just two columns user_id
and task_id
然后有一个表将它们链接在一起, user_tasks
只有两列user_id
和task_id
This way you can assign users (more than one if you need) to tasks 这样,您可以将用户(如果需要,可以分配多个)分配给任务
Use foreign keys in your user_tasks
table to ensure that that only valid user_id
s and task_id
s are used on your user_task
table 使用外键在user_tasks
表,以确保只有合法的user_id
S和task_id
s的您使用user_task
表
example tables: Users: 示例表:用户:
user_id || user_name || password
12 || jim || Il0vecATS
13 || jane || jimsuzx
Tasks: 任务:
task_id || task_name || task_descr
1 || clean up || sweep the kitchen
User Tasks: 用户任务:
user_id || task_id
12 || 1
Jim is in charge of sweeping the kitchen 吉姆负责打扫厨房
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.