[英]Display suitable information on web page from database after user logs in
I have some PHP codes and a database. 我有一些PHP代码和一个数据库。
view_subjects.php
' and ' view_tests.php
' respectively using SELECT * ..
SELECT * ..
分别登录并查看页面“ view_subjects.php
”和“ view_tests.php
”上的所有主题和所有测试SELECT * ..
CREATE VIEW II AS SELECT * subjects WHERE semester='II';
CREATE VIEW II AS SELECT * subjects WHERE semester='II';
And Views I, III, IV respectively. SELECT * FROM [viewname]
on step 3. Eg: SELECT * FROM [I] , SELECT * FROM [II], ... SELECT * FROM [IV]
SELECT * FROM [viewname]
。例如: SELECT * FROM [I] , SELECT * FROM [II], ... SELECT * FROM [IV]
Is my approach correct? 我的方法正确吗?
If so, how can I get the semester name after if he/she logs in Otherwise, how should I approach this problem? 如果是这样,他/她登录后如何获得学期名称?否则,我该如何解决这个问题?
Edit My problem is to add a filter. 编辑我的问题是添加一个过滤器。 I want users to see their subjects and tests based on the semesters they are in. Semester is an attribute of the student table along with roll_no and password.
我希望用户根据他们所在的学期查看他们的主题和考试。学期是Student表的属性以及roll_no和password。
I hope this makes sense, Im not going to write code as i dont know what you are working with there, but for situation like this, Following will be the basic idea. 我希望这是有道理的,我不会编写代码,因为我不知道您在那里使用的是什么,但是对于这种情况,以下将是基本的想法。
Method one(i do not prefer this) 方法一(我不喜欢这样)
Add a current_semester field in student table, where you store semester id. 在学生表中添加current_semester字段,用于存储学期ID。 This is to be updated every time a student completes a semester.
每当学生完成一个学期时,此信息都会更新。
before loading your information page, save the value of current_semester in a variable, and use something like, "SELECT * FROM [semester table] WHERE id = [current_semester]" 在加载信息页面之前,将current_semester的值保存在变量中,并使用类似“ SELECT * FROM [semester table] WHERE id = [current_semester]”的名称
This will give you the current semester of his/her semester where ever you want but it will not save his semester history. 这将为您提供他/她本学期的当前学期,无论您要去哪里,但都不会保存他的学期历史。
Advised Method(using different table to save student's semester history) 建议的方法(使用不同的表格保存学生的学期历史)
Advise: Use Laravel, Eloquent makes this sort of work extremely easier. 忠告:使用Laravel,Eloquent使这种工作非常容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.