I need to make a project of making a Professor timetable retrieval system.I plan to create aa html page and make a drop-down menu use some CSS scripting and php; selecting the professor's name and day of the week. This directs to the database where the selected professor's table is stored and then it must show in result that day professor's schedule.
I'm making a 6 tables that would like Monday,Tuesday...Saturday each table having attributes p_id,p_name,period 1,period 2,...,period 8.
My exact question is how to retrieve the specific professor's data on a particular day?
You mention that you will be using PHP. Have you set up your database tables yet?
As a rough guess, you will need at least a professor
table and a professor_appointment
table. The professor
table could have an auto-incrementing id
, personal name fields and whatever else you deem relevant.
The professor_appointment
will have a professor_id
field, which is a foreign key link to the professor
table. It will also need start_time
and end_time
fields, maybe title
, description
etc.
To retrieve the specific professor's data on a particular day, you would need a query like:
SELECT pa.*
FROM professor_appointment pa
INNER JOIN professor p ON pa.professor_id = p.id
WHERE p.id = 1
AND DATE( pa.start_time ) = '2017-07-20'
ORDER BY pa.start_time ASC;
This would retrieve all of the appointments on 20th July 2017 for the professor with id 1 in the professor
table.
A couple of things possible worth explaining in this SQL query:
p
after the professor
table is its alias and every reference thereafter to the professor
table just uses the alias p
. DATE( pa.start_time )
The DATE function is just wrapped around the start_time
field to effectively remove the time elements of the field (hours, minutes etc) to just leave the date itself for simple comparison.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.