Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
c159Feb1215.notebook
1
February 12, 2015
Loops need to:
c159Feb1215.notebook
2
February 12, 2015
The condition is asked before making the decision to enter which means it is possible not to enter the loop.
c159Feb1215.notebook
3
February 12, 2015
Since the condition is atthe bottom of the loop wewill always execute at leastonce.
Note the semicolonat the end of the condition in thisstructure.
c159Feb1215.notebook
4
February 12, 2015
Usually there is no semicolon here, but it is ok.
c159Feb1215.notebook
5
February 12, 2015
The set, the check and the change are all doneinside the for. Frequently you will se $ct++ toincrement $ct.
c159Feb1215.notebook
6
February 12, 2015
Example I start out with an html page to gather the data and pass theinformation to the php which processes it.
c159Feb1215.notebook
7
February 12, 2015
I reveive the data and store it as $wklb and $wkoz.I then convert the weight to ounces and print out the number of ounces.If the ounces are less than 17 then I use the $firstlb charge. If I executethe else I use a loop to help me figure out the price.In the loop I add the $every4oz to add to the cost and I then subtractthe four ounces from the weight.
c159Feb1215.notebook
8
February 12, 2015
c159Feb1215.notebook
9
February 12, 2015
The single quote does not resolve the variables.
The double quote does.
c159Feb1215.notebook
10
February 12, 2015
Now we are going to startto work with MySQL. Firstwe will create tables andquery those tables usingPUTTY as our tool.
c159Feb1215.notebook
11
February 12, 2015
We will execute Putty. It is free and can be downloaded for your computers.
c159Feb1215.notebook
12
February 12, 2015
I entered the host and now I am going to use Colours to set thebackground to white and theforeground to black text.
c159Feb1215.notebook
13
February 12, 2015
c159Feb1215.notebook
14
February 12, 2015
c159Feb1215.notebook
15
February 12, 2015
The first login will get you into cisweb.Then we need to specify using MySQLand login for that.
c159Feb1215.notebook
16
February 12, 2015
I am using my username, you need to use yours.Note I have specified using mysql.
Enter the MySQL passwordyou were sent.
c159Feb1215.notebook
17
February 12, 2015
I can create databasesbut students do nothave that power.You have been assigneda couple of databaseswhich you can seeby:show databases;
Once you use one of yourdatabase the database changesand you can now createtables.
c159Feb1215.notebook
18
February 12, 2015
I have now created a table within mydatabase that I called aaatest.I have an int of 4 characters as my id,a name as string/text/character using varchar which means variable length.Note that major could be char(2) sinceit is a fixed character size of 2. The gpais a decimal with 3 characters, 2 of whichare decimals.
c159Feb1215.notebook
19
February 12, 2015
Gets a description of the database.
c159Feb1215.notebook
20
February 12, 2015
Now, following the handout,I am inserting a recordinto the testfirst table.
c159Feb1215.notebook
21
February 12, 2015
Note numeric are not inquotes by varchar or charfields are enclosed inquotes.
c159Feb1215.notebook
22
February 12, 2015
select *from testfirst;
will show all of therecords and all thefields on each of the record.
c159Feb1215.notebook
23
February 12, 2015
If you put a record in and you want to delete it then you can use the delete command andidentify the record to delete. In this case,the record with an idno of 1999 will bedeleted.
c159Feb1215.notebook
24
February 12, 2015
Here I want to change a recordusing the update. I wanted to changethe idno from 33333 to 3333 forthe record where the name is'Robert Brooks'.
c159Feb1215.notebook
25
February 12, 2015
Could have beenchar(12) since fixedwidth.
c159Feb1215.notebook
26
February 12, 2015
List the fields that I want to see.
Now I only want to see those fields forrecords where the major is CI.