Class07 PHP: loops and includes

Slides:



Advertisements
Similar presentations
Murach's PHP and MySQL, C2© 2010, Mike Murach & Associates, Inc.Slide 1.
Advertisements

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 PHP and MySQL, C4© 2010, Mike Murach & Associates, Inc.Slide 1.
Murach's PHP and MySQL, C4© 2010, Mike Murach & Associates, Inc.Slide 1.
Class03 Introduction to Web Development with PHP MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University.
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.
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.
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.
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.
PDO Database Connections MIS 3501, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 3/8/2016.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
PDO Database Connections
© 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)
PHP: includes MIS 3501 Jeremy Shafer Department of MIS
Form Data (part 1) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
PDO Database Connections
Unit 4 – Functions and Include Files
How to get data from a form
© 2010, Mike Murach & Associates, Inc.
PDO Database Connections: Getting data out of the database
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
Introduction to JavaScript
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
PDO Database Connections: Getting data out of the database
© 2010, Mike Murach & Associates, Inc.
Form Data (part 2) MIS 3501 Jeremy Shafer Department of MIS
A second look at JavaScript
PDO Database Connections
Organize your code with MVC
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
Introduction to relational databases and MySQL
Sessions and cookies (part 1)
PDO Database Connections
© 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
Class05 How to get data from a form
MySQL Backup, Transfer and Restore
© 2010, Mike Murach & Associates, Inc.
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
Programming Control Structures with JavaScript Part 2
Class11 Introduction to relational databases and MySQL
Loops and Arrays in JavaScript
Form Data (part 1) MIS3501 Jeremy Shafer Department of MIS
Introduction to JavaScript
© 2015, Mike Murach & Associates, Inc.
MVC – Model View Controller
© 2010, Mike Murach & Associates, Inc.
© 2015, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
Presentation transcript:

Class07 PHP: loops and includes MIS 3501, Fall 2015 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/15/2015

Course Overview We are here. MySQL To do: HTML & CSS Weeks 1 & 2 PHP Weeks 3 & 4 PDO Week 7 MySQL Weeks 5 & 6 We are here. 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)

© 2014, Mike Murach & Associates, Inc. What 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.

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

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

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

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

Some more advanced conditional statements 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 … © 2014, Mike Murach & Associates, Inc.

Some more advanced conditional statements(2) 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! © 2014, Mike Murach & Associates, Inc.

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

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

© 2014, Mike Murach & Associates, Inc. Built-in functions used to assemble content from different files. 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. The exit and die functions do exactly the same thing: completely terminate further processing of the php page. © 2014, Mike Murach & Associates, Inc.

Moving up and down the hierarchy of our server’s file system 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 © 2014, Mike Murach & Associates, Inc.

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

© 2014, Mike Murach & Associates, Inc. A loop that stores the numbers 1 through 5 in a string © 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

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

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