Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class06 Conditional Statements MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/10/2015 © 2014,

Similar presentations


Presentation on theme: "Class06 Conditional Statements MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/10/2015 © 2014,"— Presentation transcript:

1 Class06 Conditional Statements MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/10/2015 © 2014, Mike Murach & Associates, Inc. 1

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

3 MySQL Weeks 5 & 6 HTML & CSS Weeks 1 & 2 PHP Weeks 3 & 4 PDO Week 7 Course Overview 3 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.

4 Recall! © 2014, Mike Murach & Associates, Inc. 4 Recall also that the values of variables can change… This differentiates them from constants (e.g. π, φ)

5 And there are many types of vars! © 2014, Mike Murach & Associates, Inc. Slide 5 For starters, we’ll just think about these four

6 © 2014, Mike Murach & Associates, Inc. Slide 6

7 © 2014, Mike Murach & Associates, Inc. Slide 7

8 © 2014, Mike Murach & Associates, Inc. Slide 8

9 © 2014, Mike Murach & Associates, Inc. Slide 9

10 BORING! What would be more important is figuring out how to teach the program how to react conditionally Based on pre-defined parameters This is the notion behind if statements and relational operators Assigning Variables is Important, But it is Still Rather Pedantic Applies to Both Genders

11 Making Comparisons © 2014, Mike Murach & Associates, Inc. Slide 11

12 Conditional Statements (simple) © 2014, Mike Murach & Associates, Inc. Slide 12

13 A function, or a procedure, or a method, or a subroutine is a set of code designed to do the same thing over and over again It almost always returns a value Consider the “Add to Cart” Button We allow it to produce different results by passing it parameters And if We’re Doing it More than Once We Create a Function

14 Functions © 2014, Mike Murach & Associates, Inc. Slide 14

15 © 2014, Mike Murach & Associates, Inc. Slide 15 Discuss – Based on your reading of the textbook, what is the difference between isset() and empty()? What do they do for us?

16 © 2014, Mike Murach & Associates, Inc. Slide 16 Very Useful!

17 © 2014, Mike Murach & Associates, Inc. Slide 17 <?php //get data off the form $description = filter_input(INPUT_POST,'product_description'); $price = filter_input(INPUT_POST, 'list_price',FILTER_VALIDATE_FLOAT); $discount = filter_input(INPUT_POST, 'discount_percent',FILTER_VALIDATE_INT); ?> Could be INPUT_POST or INPUT_GET

18 © 2014, Mike Murach & Associates, Inc. Slide 18 <?php //get data off the form $description = filter_input(INPUT_POST,'product_description'); $price = filter_input(INPUT_POST, 'list_price',FILTER_VALIDATE_FLOAT); $discount = filter_input(INPUT_POST, 'discount_percent',FILTER_VALIDATE_INT); ?> Corresponds to the name of a form input tag

19 © 2014, Mike Murach & Associates, Inc. Slide 19 <?php //get data off the form $description = filter_input(INPUT_POST,'product_description'); $price = filter_input(INPUT_POST, 'list_price',FILTER_VALIDATE_FLOAT); $discount = filter_input(INPUT_POST, 'discount_percent',FILTER_VALIDATE_INT); ?> Specifies the type of validation. See PHP 5 Predefined Filter Constants here: http://www.w3schools.com/php/php_ref_filter.asp http://www.w3schools.com/php/php_ref_filter.asp

20 © 2014, Mike Murach & Associates, Inc. Slide 20 <?php //get data off the form $description = filter_input(INPUT_POST,'product_description'); $price = filter_input(INPUT_POST, 'list_price',FILTER_VALIDATE_FLOAT); $discount = filter_input(INPUT_POST, 'discount_percent',FILTER_VALIDATE_INT); ?> The value of $discount will be either: 1.The value of ‘discount_percent’ provided by the user 2.FALSE (because the value was not an integer) 3.NULL (if there was no ‘discount_percent’ in the form post at all.) The value of $discount will be either: 1.The value of ‘discount_percent’ provided by the user 2.FALSE (because the value was not an integer) 3.NULL (if there was no ‘discount_percent’ in the form post at all.)

21 What if the user puts the wrong data in? What if the content we need is somewhere else? What if we want to go back to where we were with the data from where we are? If this happens… we pass control! NOW! We Have a Problem…

22 © 2014, Mike Murach & Associates, Inc. Slide 22

23 © 2014, Mike Murach & Associates, Inc. Slide 23

24 Conditional Statements (fancy!) © 2014, Mike Murach & Associates, Inc. Slide 24

25 Exercise © 2014, Mike Murach & Associates, Inc. Slide 25


Download ppt "Class06 Conditional Statements MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/10/2015 © 2014,"

Similar presentations


Ads by Google