我想将学校的时间表/班级时间表存储到mysql数据库中。需要帮助才能理解。这是php表单
Period No. Monday Tuesday Wednesday Thursday Friday Saturday
1 Subject Subject Subject Subject Subject Subject
Classrrom Classroom Classroom Classroom Classroom Classroom
2 Subject Subject Subject Subject Subject Subject
Classrrom Classroom Classroom Classroom Classroom Classroom
3 Subject Subject Subject Subject Subject Subject
Classrrom Classroom Classroom Classroom Classroom Classroom
4 Subject Subject Subject Subject Subject Subject
Classrrom Classroom Classroom Classroom Classroom Classroom
5 Subject Subject Subject Subject Subject Subject
Classrrom Classroom Classroom Classroom Classroom Classroom
6 Subject Subject Subject Subject Subject
Classrrom Classroom Classroom Classroom Classroom
7 Subject Subject Subject Subject Subject
Classrrom Classroom Classroom Classroom Classroom
8 Subject Subject Subject Subject Subject
Classrrom Classroom Classroom Classroom Classroom
如何将此表单插入数据库或此类学校时间表的任何其他解决方案。每天需要不同的科目和课堂,总时间为8.请帮帮我
答案 0 :(得分:1)
CREATE TABLE timetable
(`Period` int, `Monday` varchar(17), `Tuesday` varchar(17), `Wednesday` varchar(17), `Thursday` varchar(17), `Friday` varchar(17), `Saturday` varchar(17))
;
INSERT INTO timetable
(`Period`, `Monday`, `Tuesday`, `Wednesday`, `Thursday`, `Friday`, `Saturday`)
VALUES
(1, 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom'),
(2, 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom'),
(3, 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom'),
(4, 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom'),
(5, 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom'),
(6, 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom'),
(7, 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom'),
(8, 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom', 'Subject-Classroom')
;
+--------+-------------------+-------------------+-------------------+-------------------+-------------------+-------------------+
| PERIOD | MONDAY | TUESDAY | WEDNESDAY | THURSDAY | FRIDAY | SATURDAY |
+--------+-------------------+-------------------+-------------------+-------------------+-------------------+-------------------+
| 1 | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom |
| 2 | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom |
| 3 | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom |
| 4 | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom |
| 5 | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom |
| 6 | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom |
| 7 | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom |
| 8 | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom | Subject-Classroom |
+--------+-------------------+-------------------+-------------------+-------------------+-------------------+-------------------+
现在使用 PHP ,您可以这样解析:
<?php
$class = explode("-", $class);
// Subject: $class[0];
// Classroom: $class[1];
?>
答案 1 :(得分:1)