Summary notes created by Deciphr AI
https://www.youtube.com/watch?v=Rkg731t47dc&authuser=0The transcript outlines a comprehensive tutorial on building an assignment tracker using PHP, MySQL, and the Model-View-Controller (MVC) architecture. The application allows users to categorize assignments by course, view assignments per course, and manage courses and assignments through a mobile-first design. The tutorial covers setting up the database with tables for assignments and courses, implementing PHP logic for CRUD operations, and creating a responsive front-end using HTML, CSS, and Sass. It emphasizes error handling, user interaction, and styling for a seamless user experience. The tutorial is detailed, providing step-by-step guidance for developers.
"Today we're going to build an assignments tracker and the assignments have categories. They're categorized by the course name."
"This assignment tracker is also available in a mobile view and actually design for mobile first."
assignment_tracker
, with two tables: assignments
and courses
.assignments
table includes columns for id
, description
, and course_id
, with course_id
serving as a foreign key linked to the courses
table.courses
table includes columns for course_id
and course_name
."Let's add the database name. We'll call this assignment_tracker and I'll click create."
"In the assignments table, course id will be a foreign key."
index.php
file serves as the controller, coordinating interactions between the model and view.database.php
file in the model folder establishes a connection to the database using PHP Data Objects (PDO)."Let's start with Visual Studio Code and start building the MVC project for our assignment tracker."
"In the model folder, the first file I'm going to create is the database.php file, and it's going to create a connection to the database."
error.php
file that displays error messages and provides a link to return to the main list."We'll catch a PDO exception and we'll just call that e. You could call it error the full word if you wanted to."
"Between the header and footer, we'll have the rest of our template for our error page."
assignments_db.php
file to interact with the assignments table, including fetching, adding, and deleting assignments.get_assignments_by_course
function retrieves assignments based on a specified course ID or all assignments if no ID is provided.delete_assignment
and add_assignment
functions manage the removal and addition of assignments in the database."The first function is the one that we will use the most. It will be the default for loading all of the assignments that we view."
"We'll create a delete function and eventually an add function which will create an assignment."
get_courses
function retrieves all courses from the database, ordered by course ID."We'll start this file with PHP and then we'll say function get_courses. No parameter, we just want to get all the courses."
Get Courses Function:
Prepares a query to fetch all courses.
Executes the query and fetches all results.
Returns the list of courses after closing the cursor.
"We fetch all but we want this to say courses, we close the cursor and we return the courses."
Get Course Name Function:
Checks if the course ID is valid; returns "all courses" if not.
Modifies the query to select the course name based on the course ID.
Binds the course ID parameter and executes the query.
Fetches and returns the course name.
"If the course id doesn't exist, if it's false or null, we're going to return the string all courses."
Explains the condition for returning all courses when no valid course ID is provided.
"Course underscore name is going to equal course and then course name and we'll return the course name."
Delete Course Function:
Requires a course ID to delete a course.
Prepares and executes a delete query using the course ID.
No return value as the function is purely for deletion.
"We're just deleting that one course so that is the end of that function."
Add Course Function:
Takes a course name parameter to add a new course.
Prepares an insert query with the course name.
Binds and executes the query to add the course.
"Insert into courses and then we need just a little bit different, we'll say course name which is the value."
Controller Initialization:
Requires necessary files from the model folder.
Sets up data handling for assignment IDs, descriptions, and course names.
Handles both POST and GET requests for course IDs.
"We have to start out by requiring what we need from the model so we'll look to the model folder."
Describes the initial setup of the controller by requiring necessary files.
"The action variable and the action is what's actually going to help us pick the different routes."
Handling Actions and Routing:
Defines default action to list assignments.
Uses a switch statement to handle different routes based on the action variable.
Prepares data for views, including course names and assignments.
"The default action is going to be to list the assignments on the page."
Clarifies the default action for the controller.
"As we take different routes throughout our controller, we're going to need different data to send to our templates."
Assignment List Template:
Starts with including header and footer files.
Sets up a section with a header and form for selecting courses.
Uses a dropdown menu for course selection and a "Go" button for submission.
"We'll start out with a section element, let's give this an id equal to list and a class equal to list."
Describes the initial setup of the assignment list section.
"We also want a form at the top of this application where users can select from a drop menu."
Displaying Assignments:
Checks for assignments and loops through them to display.
Includes options to delete assignments via a form.
Provides messages when no assignments are available.
"If there are assignments, we want to loop through those so I'll say assignments as assignment."
Details the process of looping through and displaying assignments.
"No assignments exist for this course yet."
Form and Button Setup:
Uses hidden inputs to control routing through the controller.
Includes a button with a delete symbol for removing assignments.
"This class will be equal to a remove dash button and I'm going to paste in a little emojipedia cancel delete sign."
"We've got the reply no assignments exist yet, and that is because we don't have any course ids."
"We'll start a form and this action is once again going to just go to the root for the controller, the method will be equal to post."
"If we don't have courses, we're just going to say no courses exist yet."
"The first route we'll add is a case, and then we'll say list_courses."
"If we tried to delete a course that had assignments attached to it, we would get an error."
"We're going to first look at the extensions if you don't have live SAS compiler that is what I recommend to use."
_colors.scss
, _mixins.scss
, _base.scss
, _list.scss
, and _ad.scss
."You don't have to use the underscore in the import, but you need to name the file with an underscore to indicate to SASS it's a partial."
view/css
."When Live SASS Compiler generates or compiles my CSS, it minifies it and then it saves it in the view folder and then in the CSS folder."
fontColor
, inverseFontColor
, and borderColor
."I've created these different variables to use as I create the styles throughout the application."
flexCenter
and flexStart
, which manage flexbox properties."Mixins are unique to SASS and they definitely help out because then you can avoid typing things that are repetitive over and over again."
box-sizing: border-box
."The base file is where you really set out the foundation for your page."
"It's also very handy to use mixins on your media queries."
"By defining these list definitions, we should see a lot of changes and both these changes will happen on both the course list and the view and add assignments page."
"We have a green go button; the rest doesn't look like it changed too much yet."
"It's always good to test the applications out."
"Remember to keep striving for daily progress instead of perfection."