MySQL and PHP - CIS159/CIT32

Weekly Schedule

Week Information
Assignments due in one week unless otherwise stated. I may add some things during the week, so double check the schedule each week! Please keep copies of all work you submit until you receive your final grade at the end of the semester.
Week#15
Week of December 8th
The final exam is due on December 17th at 9:00AM.
Final Exam
The code you need for problem #2
Required Status Sheet
Week #14
Week of December 1st
This week we will deal with sessions, cookies and some data manipulation. I will look at data manipulation on Tuesday since the lock down is happening and we will look at cookies and sessions on Thursday.
Examples you can load onto your area on the server to test 4/30 (functions)
Examples you can load onto your area on the server to test 5/2 (sessions and cookies)
Assignments:
Decoding challenge:
I want you to decode a word and return the decoded result. You need to use explode for this assignment. Take in the code dtgcm and find the location of each in the alphabet (I want you to explode the alphabet into an array). When you find the letter, back up by 2 and retrieve that letter to decipher the code. That means the result will be break because backing up 2 letters from d gets b and backing up two letters from t gets r etc. Now you should include the code that when you start with a backing up 2 gets y and when you start with b, backing up 2 gets z.
Cookie assignment: Write a series of programs to place a cookie, check a cookie, delete a cookie.
Session assignment: Write a series of programs where you take in pay per hour and hours worked and receive it in another program and calculate and show pay. Use sessions to hold and access the data.
Week #13
Week of November 24th
The looking at retrieving data in different ways question has some samples here:
Retrieving data from an array
Images Second Group PHP zipped
Email Group One PHP zipped
Thursday we will look at images and maybe start email. Check back!
Assignments:
Quiz on databases and images Just to clarify when you bring up a random picture I want the address taken from the database table to be used.
PLEASE pass in the random number guess game that was assigned last week, I want to go over it when I look at sessions.
Week #12
Week of November 17th
We will finish up arrays and then move on to functions.
Function Group PHP zipped
Function Built In Group PHP zipped
Images First Group PHP zipped
Assignments:
Write the program to guess a number between 1 and 25. Use the random number function to generate the number to guess. This should be written on one php page meaning the input for the guess and the processing are on the same page. Be sure you are using function(s) in this assignment. Note: I want you to tell the user whether it is high, low or correct and let them keep guessing until it is correct.
Check back!
Week #11
Week of November 10th
Array Group Third Rest PHP zipped
Assignments:
QUIZ: Array Quiz
Write the following programs.
Problem 1: I want you to set up arrays to take a course number and get the associated course name and the professor teaching the course. I want you to use associative arrays where the first key would be a specific course number and that would get a course name. In the basic version of this, you would then go to a second array and use the course name to extract the professor. As you can see from the output below, I used CIS120, CIS121, CIS122, CIS155, CIS159.
Problem 2: Do the same problem but set it up a different way. Look at my examples for some alternatives.
Problem 3: I want to set up array(s) to contain the departments in the town that you can call for help like fire, policy, light, water. It should include the address, the manager and the phone number.
Week #10
Week of November 3rd
We will start to look at arrays this week after we finish up a few things on maintenace of database tables.
Array Group First PHP zipped
Array Group Second PHP zipped
Array Group Third Start PHP zipped Assignments:
In class or at home quiz (Either finish or do it at home if it is not complete at the end of class.):
On the first two problems, I want you to play computer - you can then test your answer, but I want you to go through the process of figuring out what the output would be and send me the answers. The third involves some coding.
OK, the original plan was to put up what you see now and have you play computer, but it was late at night and I put up the answers. Ah well, I think it is still worth doing. If you were in class verify with me you were there and that counts.
question 1 and question 2
question 3
Math Array
Assignment:The statements Multiply by 0, Multiply by 1 are stored in a one dimension array and displayed. You need to extract the message from the array and display it before you show each group. You are going to display the math facts and the answers. The answers need to be stored in a two dimensional array. Set up a two level table to print out the math facts and get the answer from the two dimensional array. The two multipliers are the indexes that allow you to extract the answer. I used a nested while loop to do this and another time I used a nested for loop.
Week #8/Week #9
Week of October 20th/October 27th
This week we are going to look at relational databases and discuss some of the theories of normalization.
Look at the presentation on normalization.
One example: Payroll example
Continue looking at accessing the database through PHP as well as maintenance.
Third Connect Group zipped - connecting to a database
Note if any of these examples have an .inc connection change it to .php. At one point I had made a couple of password files .inc and that is not a good security move.
Assignments:
Payroll database Explanation to use below
To do in PHP: Relational Database Assignment
Create a table using php script. The table should have 5 fields with an least one numeric field. You then need to populate the table with at least 5 records.
Next, I want you to write code to update your database table. I want you to let the user choose whether they want to add, change or delete (this means presenting all choices and acting on their decision). I then you want to take in the needed data and make the add, change or delete happen. When you are doing a change you must figure out a way to decide if you are adding data to the field, deleting data from the field or changing the data from the field. I want you to start with a menu and make the choice and then bring up the approriate form to fill out, send the information to be updated. You should be able to update all but the key field. I want yours to be far better than my individual update programs. The completeness of the processing will impact the grade.
Week #7
Week of October 13th
Continuing with MySQL and then looking at connecting to the database through PHP.
First Connect Group zipped - connecting to a database
Second Connect Group zipped - connecting to a database
Reference to check: mysqli
You should do some research on using mysqli and connecting to the mysql database.
Assignments:
SQL in PHP assignment
Please also add flipping the name from last/first middle to first middle last as #15 on this assignment.
Week #6
Week of October 6th
We will continue looking at MySQL this week. Check chapter 9 in the text and a couple of the many online resources as well as my examples.
Notes:
Keys, indexes etc.
Subqueries
Multiple tables
Functions
Assignments:
MySQL assignment: Second SQL assignment
Again, for those who took Oracle, please notice the similarities and differences.
Check back and see how far we got!
Week #5
Week of September 29th
We will continue looking at MySQL this week. Check chapter 9 in the text and a couple of the many online resources as well as my examples.
We will start with these and move on as time allows:
Beginning MySQL notes
Data types
More SQL
Notes:
Keys, indexes etc.
Subqueries
Multiple tables
Functions
Assignments:
SQL assignment
Note that in the sample, I took an example I had used in Oracle. You need to check out how to do the date in MySQL.
Check back!
Week #4
Week of September 22nd
We will continue looking at the loop examples and then move on to look at alternates for if and loop.
Somehow I managed to skip the examples of elseif and case structure (switch). You will find them in ThirdGroupPlusPHP.zip.
Third Group Plus PHP zipped - elseif and case
Fourth Group PHP zipped - loops
Fifth Group PHP zipped - alternative if and loops
Sixth Group PHP zipped - functions
We did not get to SixthGroupPHP because I wanted to make sure everyone could log in using putty. We will return to look at functions after we have worked with MySQL.
This week we are also going to start looking at MySQL. I want to get the fundamentals of both PHP and MySQL out of the way! Note that we will not get through all the examples this week, I just wanted to put these out for you to use to get started with MySQL.
Your book covers this I think in chapter #9, so...
First we are going to look at MySQL through putty and then we will incorporate it into PHP.
You will be accessing MySQL on the cisweb server. Information about MySQL is available at their web site. MySQL site
Information about using it at BCC is on this handout. Using MySQL on the cisweb server
Note: You will need your cisweb username and password. If you have not gotten it yet, contact me. You should also get a copy of PuTTY to use with MySQL if you plan to work from home. PuTTY is available in the labs. Two sites that can be used to download PuTTY are:
PuTTY
PuTTY
Here is an example sheet for use when you are creating databases and tables in putty: Using putty to create a database and table
Putty Notes
Here is another example sheet for use when you are maintaining and doing queries similiar to the ones I have assigned. Using SQL with MySQL
You should be looking up tutorials on SQL. Two that I think are good are:
SQL Tutorial (based on MySQL)
A Gentle Introduction to SQL This is especially helpful for someone who has had Oracle because it shows comparisons between the two versions.
You are allowed to have two databases (each can have multiple tables), under your cisweb. You can see the names of the databases if you login to mysql through putty and give the command show databases;
Beginning MySQL notes
Data types
More SQL
Assignments:
Write a program to do the algebraic equation x = a(b+6)/2 multiple times within loops that vary a and b. The variable a should start at 1 go to 10 and increment by 1. The variable b should start at 2 and go to 10 and increment by 2. When you display the answer show the formula in php.
I want you to do this three times: once with a for...next, once with a do...while and once with a while.
Please work with getting in to mysql using putty. It would be great if you followed the notes that say Beginning MySQL notes and create a table. Not to pass in - just to make sure you are all set.
MySQL and putty
Week #3
Week of September 15th
This week we will start by looking at if statements within PHP so check out the topic.
You should read the chapter on decisions in the text book. Please read along in the text book at the rate of about a chapter a week. I really think of the textbook largely as a reference.
Third Group PHP zipped - decisions
Boston Tea party example zipped
Third Group Plus PHP zipped - elseif and case
Fourth Group PHP zipped - loops
Check back and see how we are doing.
Please look at "Go West Across America with Lewis and Clark" which is where I got the idea for the Boston Tea Party game. Lewis and Clark adventure
This week we are going to look at decisions and developing a multipage site. Depending on time, we may start loops.
Assignments:
I would like you to write an educational game for kids about some event or series of facts. It should be something along the lines of what I did for the Boston Tea Party. It should have a minimum of 3 pages.
IF Quiz
Week #2
Week of September 8th
I will be available for help Monday at 10:00 in my office, I will be available Tuesday and Thursday at 2:00 in a lab, hopefully K101 on Tues and K118 on Thurs, If you need help with something, now would be the time to ask your questions!
This week we will start PHP. Please look at the beginning PHP examples that I have listed below. There are additional examples from previous classes and PowerPoints available at the web site. Note that you are doing PHP and MySQL on the server so you do not have to attempt to set it up.
Chapter 1 is exploring the environment and chapter 2 is using variables and input. I would read those chapters if you have the text or look up something comparable in another book or online.
Uploading to the Web: These are the handouts I give out in CIS120 that reference using cisweb. Note we now prefer cisweb.bristolcc.edu instead of cisweb.bristol.mass.edu.
We will look at login to cisweb this week so check the notes on the Smartboard and the accompanying audio as well as the notes below.
To load things up on the Internet, we use WINSCP. Please read the WINSCP and cisweb information: (note that in my examples I use cisweb.bristol.mass.edu as the host, we are now using cisweb.bristolcc.edu as the host although the old one is still supported).
Here is information about using cisweb and WINSCP at BCC
Talks more specifically about portfolio We will be looking at making a portfolio later in the semester.
If you want to download WINSCP at home, you can find it at this address.
WINSCP
The examples we will go over first are:
First Group PHP zipped
First PHP list with code
Second Group PHP zipped
Assignments:
For all assignments, send me the address that I can run in the browser to test your program and also send a copy of the code.
Quiz this is one of those quizzes where you can talk things through with others in the class, but each person has to do it and pass in their version.Quiz
Homework: Memo assignment Make up 5 names and use the 7 days of the week. and notice in my example I have you select a first name but I put out the whole name. You can make up the names. Also note that the select is Wed but in the memo I use Wednesday.
Week #1
Week of September 1st
Read chapter #1 which talks about ways to use PHP and MySQL in PHP/MySQL Programming or read about the topic in another text you have elected to use. We will start off the semester with HTML/XHTML. If you have already had CIS122/44 or have previous experience, this will be a review. If you have taken CIS120/17, you have already been introduced to HTML. For others I suggest that you read chapter #1 carefully and use resources at the page for CIS122/44 or other resources on the web to accquaint yourself with HTML.
A great reference for writing HTML is W3Schools
The students in this class have a variety of backgrounds, so for some HTML is review and for others it is relatively new.
Handout on using WinSCP3 Note instead of the host as cisweb.bristol.mass.edu we are now using cisweb.bristolcc.edu.
Note that WinSCP3 is available as open source software and you can download it for home use.
When logging in at school, you should not enter your password and you should not save. If you do not enter the password you are prompted for it in a session, but it is not saved. This provides you with some security for your site. You should be getting a username/password for the BCC site at the end of this week.
We will be working exclusively off the BCC site. You do not need to install PHP or MySQL, they are on the server.
We will experiment with logging in to the server and look at some of the examples at the site located in Beginning PHP examples zipped under Site Resources/Code Examples.
You can check HTML examples under my CIS120 and CIS122 sites. This example covers some of the fundamentals: html5example.html
Assignments:
If you are new to HTML, I want you to build a web page and upload it to the server (that cannot be done until you get your username and password). The page should include at least list, tables, CSS and forms.
If you are experienced with HTML, I want you to develop a page that challenges you and uses elements that you stretch your knowledge - this is the time to explore more CSS or forms - experiment!

Google
WWW www.pgrocer.net

Send e-mail to Priscilla Grocer: Priscilla.Grocer@bristolcc.edu

Back to the Top
Return to home page
Return to previous page