Mike Schultz W8 Training.com logo with picture of me.


Case 5 MVC

MVC Iteration 1: Lifts

Model

Lifts Table
Column Name Constraint Type Reference Table Reference Column Data Type Size
lift_id primary key integer maximum
lift_name not null varchar 40
lift_image_path not null varchar 50
lift_image_alternative_text not null varchar 125
lift_instruction not null clob maximum


View

This is a mockup of the admin page that the administrator will be able to use to add lifts to the database. It is basically just going to be a form where he will be able to enter text.

A mockup of the admin form page

This is a mockup of what a user will see when he queries a lift from the database. The image will only be one image edited to appear to have two or three stages of the lift. In this example I drew a stick figure. Next week I will begin photographing lifts for the site.

A mockup what a user will see when they query a lift.


Control

The pseudo code for the administrative side of this iteration will be in a controller php document⋅

Get the connection to the database.

Get the information from the “Add Lift” form.

Test inputs for all the sections of the add lift page to make sure they are there.

If all inputs test successfully use the information from the form.

Collect the inputs from the form into variables.

Insert those variables as values using a prepared statement.

Test to see if the query worked.

If it worked, send them to success.php.

If it failed send them to addcontent.php with the failure message.



The pseudo code for the user side of this iteration will be in another controller php document.

Get the connection to the database.

Validate the user input.

Enter user input into a variable for a prepared statement.

Run input through prepared statement that queries the database for that lift.

Test to insure the prepared statement works.

Close the prepared statement.

Test to see if the query worked.

If a value for the entered lift was found then:

count the columns into an arrays.

place the elements of that array into an unordered list.

If the no value was matched for the lift:

Send them to the lift index page.