Class07 PHP: loops and includes MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/15/2015.

Slides:



Advertisements
Similar presentations
Murach’s C# 2010, C6 © 2010, Mike Murach & Associates, Inc.Slide 1.
Advertisements

Murach’s SQL Server 2008, C6© 2008, Mike Murach & Associates, Inc.Slide 1.
SQL for SQL Server, C6© 2002, Mike Murach & Associates, Inc.Slide 1.
Murach’s C# 2010, C3 © 2010, Mike Murach & Associates, Inc.Slide 1.
Murach's C# 2012, C3© 2013, Mike Murach & Associates, Inc.Slide 1.
Murach's PHP and MySQL, C2© 2010, Mike Murach & Associates, Inc.Slide 1.
Murach's MySQL, C2© 2012, Mike Murach & Associates, Inc.Slide 1.
Murach's PHP and MySQL, C2© 2010, Mike Murach & Associates, Inc.Slide 1.
Murach’s SQL Server 2008, C1© 2008, Mike Murach & Associates, Inc.Slide 1.
Murach’s C# 2010, C1© 2010, Mike Murach & Associates, Inc.Slide 1.
© 2013, Mike Murach & Associates, Inc.
Murach’s SQL Server 2008, C4© 2008, Mike Murach & Associates, Inc.Slide 1.
Murach’s C# 2010, C4 © 2010, Mike Murach & Associates, Inc.Slide 1.
Murach’s C# 2010, C4 © 2010, Mike Murach & Associates, Inc.Slide 1.
Murach's C , C4 © 2009, Mike Murach & Associates, Inc. Slide 1 © 2009, Mike Murach & Associates, Inc.Slide 1.
Murach's PHP and MySQL, C4© 2010, Mike Murach & Associates, Inc.Slide 1.
Murach's PHP and MySQL, C4© 2010, Mike Murach & Associates, Inc.Slide 1.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Advanced Web 2012 Lecture 4 Sean Costain PHP Sean Costain 2012 What is PHP? PHP is a widely-used general-purpose scripting language that is especially.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
Class03 Introduction to Web Development with PHP MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University.
Class02 Introduction to web development with PHP MIS 3501, Fall 2015 Brad N Greenwood Department of MIS Fox School of Business Temple University 8/27/2015.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Unit 1 – Web Concepts Instructor: Brent Presley.
Class11 Introduction to relational databases and MySQL MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University.
Class06 Conditional Statements MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/10/2015 © 2014,
Class03 Introduction to Web Development (Hierarchy and the IDE) MIS 3501, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Sessions and cookies (part 2) MIS 3501, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/19/2015.
Form Data (part 2) MIS 3502, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/10/2015 Slide 1.
Form Data (part 1) MIS 3502, Fall 2015 Brad Greenwood, PhD Department of MIS Fox School of Business Temple University 11/10/2015.
Chapter 5 Murach's JavaScript and jQuery, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
Class05 How to get data from a form MIS 3501, Fall 2015 Brad N Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/8/2015.
Sessions and cookies MIS 3501, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 4/12/2016.
© 2010, Mike Murach & Associates, Inc.
Class03 Introduction to Web Development (Hierarchy and the IDE)
Brad N Greenwood, PhD MBA
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
Form Data (part 2) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
Organize your code with MVC
Introduction to Web Development (Part 2)
Using the HTML and CSS Validation Services
PHP: includes MIS 3501 Jeremy Shafer Department of MIS
Form Data (part 1) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
Class07 PHP: loops and includes
Unit 4 – Functions and Include Files
How to get data from a form
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
Cookies BIS1523 – Lecture 23.
© 2010, Mike Murach & Associates, Inc.
Form Data (part 2) MIS 3501 Jeremy Shafer Department of MIS
Organize your code with MVC
© 2010, Mike Murach & Associates, Inc.
Building Web Applications
© 2015, Mike Murach & Associates, Inc.
© 2015, Mike Murach & Associates, Inc.
© 2015, Mike Murach & Associates, Inc.
Form Data (part 2) MIS 3501 Jeremy Shafer Department of MIS
Class07 PHP: loops MIS 3501 Jeremy Shafer Department of MIS
Class08 Using the Documentation
Class05 How to get data from a form
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
Class11 Introduction to relational databases and MySQL
© 2015, Mike Murach & Associates, Inc.
© 2015, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
Presentation transcript:

Class07 PHP: loops and includes MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/15/2015

© 2014, Mike Murach & Associates, Inc. 2 Housekeeping The exam has been rescheduled for the 24 th This gives an extra study day Tom will be scheduling a review session that week The exam is no joke I will be regrading the zero quizzes tomorrow Today is the last day to see me

What Have We Done © 2014, Mike Murach & Associates, Inc. Slide 3

MySQL Weeks 5 & 6 HTML & CSS Weeks 1 & 2 PHP Weeks 3 & 4 PDO Week 7 Course Overview 4 To do: Organize your code with MVC (week 8) Debug your code (week 9) Work with forms (week 10) Use arrays (week 11 & 12) Use sessions (week 13) We are here.

© 2014, Mike Murach & Associates, Inc. 5 What, structural, code have we learned so far? PHP code runs on the server PHP code is embedded in HTML PHP has a filter_input function that can be used to retrieve data from form posts Like any other programming language, PHP lets us store data in variables Our PHP code can take different actions based on conditional statements

© 2014, Mike Murach & Associates, Inc. 6 Objectives 1.Revisit conditional statements 2.Avoid redundant code with server-side includes 3.Avoid redundant code with loops

Conditional Statements © 2014, Mike Murach & Associates, Inc. 7

A little review… © 2014, Mike Murach & Associates, Inc. 8

A little review… (2) © 2014, Mike Murach & Associates, Inc. 9

A little review… (3) © 2014, Mike Murach & Associates, Inc. 10

© 2014, Mike Murach & Associates, Inc. 11 This error message was created using a conditional statement. Validation (that is error trapping) is just one use of conditional statements.

Some more advanced conditional statements © 2014, Mike Murach & Associates, Inc. 12 Lookie here! – Notice how we are considering three conditions in one statement. This condition reads: “if investment is empty OR investment is not numeric OR investment is less than or equal to 0 THEN …

Some more advanced conditional statements (2) © 2014, Mike Murach & Associates, Inc. 13 Notice also that if statements can be nested inside each other. Here, the “if years greater than one” condition is nested inside the else block of the first condition. Whew!

Server-Side Includes © 2014, Mike Murach & Associates, Inc. 14 (Some assembly required)

Server-Side Includes © 2014, Mike Murach & Associates, Inc. 15 Sometimes we have a portion of a web site (or web application) that we want to use over and over again. It could be something like a page header displaying a corporate logo, a copyright notice at the bottom of each page, or a piece of PHP code that was tricky to write once (so why not reuse it?)

Built-in functions used to assemble content from different files. © 2014, Mike Murach & Associates, Inc. 16 The exit and die functions do exactly the same thing: completely terminate further processing of the php page. The include and require functions are similar. They both inject content from another file into the current PHP page. The require function is the more strict of the two. If the file is not found, an warning is displayed and further processing of the page stops. Include let’s processing continue, but with a warning. These functions are just like their cousins above. They silently prevent the same content from being injected over and over again.

© 2014, Mike Murach & Associates, Inc. 17 Sometimes we choose to assemble our page based on one or more conditions. Moving up and down the hierarchy of our server’s file system

Loops © 2014, Mike Murach & Associates, Inc. 18 (Doing the same thing over and over again)

© 2014, Mike Murach & Associates, Inc. 19 A loop that stores the numbers 1 through 5 in a string This is the same as: $counter = $counter + 1;

The Future Value Calculator uses a loop © 2014, Mike Murach & Associates, Inc. 20

© 2014, Mike Murach & Associates, Inc. 21 How was this number calculated? ∑f(x i ) where f(x) = x + x*i

© 2014, Mike Murach & Associates, Inc. 22

© 2014, Mike Murach & Associates, Inc. 23

© 2014, Mike Murach & Associates, Inc. 24