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

Slides:



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

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 C# 2010, C1© 2010, Mike Murach & Associates, Inc.Slide 1.
© 2013, Mike Murach & Associates, Inc.
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 Conditions MIS 3501, Fall 2014 Jeremy Shafer Department of MIS Fox School of Business Temple University September 11, 2014.
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.
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.
Introduction to AJAX MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/4/2016.
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
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
PDO Database Connections
How to get data from a form
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 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
PDO Database Connections
Organize your code with MVC
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
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
Class08 Using the Documentation
Class05 How to get data from a form
© 2010, Mike Murach & Associates, Inc.
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
Class11 Introduction to relational databases and MySQL
Form Data (part 1) MIS3501 Jeremy Shafer Department of MIS
© 2015, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2015, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
Presentation transcript:

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

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

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.

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

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

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

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

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

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

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

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

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

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

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

© 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?

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

© 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

© 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

© 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:

© 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.)

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…

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

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

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

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