如何为此字段制作表格

时间:2015-02-17 14:07:21

标签: php mysql

这是我的导师片段形式:       I-V级学费         VI-VIII级学费         IX-X级学费         XI-XII级学费         大学水平         工程学科

根据我的Tutor Selected Segment,我会显示不同的表格。假设用户选择不同的类,如class1-5 class6-8 class8-10和engineering.How如何制作我的表列请看示例

 1.Tutor selected class I-V And class VI-VIII
    2.Tutor selected class I-V And class VI-VII AND Engineering

Here is my Db structure:
my column contains
tutorid  class1-5 class6-8 class 8-10 class10-12  collegelevel Engineering 

my question are:
1.user selected class1-5 and class6-8
INSERT INTO Tablename('class1-5,class6-8,class8-10,class10-12',collegelevel,engineering) values('class1-5','class6-8','remining column I don't have value');
2.user selected engineering
INSERT INTO Tablename('class1-5,class6-8,class8-10,class10-12',collegelevel,engineering) values('it has only engineering values' remaining column is null);
3.How to make the table for this. Here I have to keep my table column like this only.

1 个答案:

答案 0 :(得分:0)

没有。规范化您的数据库。

你的导师表:

tutor_id
tutor_username
tutor_password <-- encrypt this
...

你的班级表:

class_id
class_name

您的用户表:

user_id
user_username
user_password <--encrypt this
...

你的'去上课'(gtc)表:

gtc_id
gtc_user_id
gtc_class_id

因此,当您的用户选择一个类时,它将在going to classes表中创建一个新记录,因此它可能如下所示:

| gtc_id | gtc_user_id | gtc_class_id |
|    0   |     16      |       1      |
|    1   |     16      |       2      |
|    2   |     17      |       1      |

并在您的课程表中:

| class_id | class_name
|    0     | English      
|    1     | Maths     
|    2     | Engineering      

因此,用户16将转到课程EnglishEngineering,而用户17只能转到课程English