PHP Conditions MIS 3501, Fall 2014 Jeremy Shafer Department of MIS Fox School of Business Temple University September 11, 2014.

Slides:



Advertisements
Similar presentations
Selection Feature of C: Decision making statements: It allow us to take decisions as to which code is to be executed next. Since these statements control.
Advertisements

Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Control Structures Corresponds with Chapters 3 and 4.
Creating PHP Pages Chapter 7 PHP Decisions Making.
Objectives Using functions to organize PHP code
1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
ITC 240: Web Application Programming
Slide 1 Summary Two basic concepts: variables and assignments Some C++ practical issues: division rule, operator precedence  Sequential structure of a.
Iteration This week we will learn how to use iteration in C++ Iteration is the repetition of a statement or block of statements in a program. C++ has three.
Chapter 4 Functions and Control Structures PHP Programming with MySQL.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
C++ for Engineers and Scientists Third Edition
CSCI 116 Week 3 Functions & Control Structures. 2 Topics Using functions Using functions Variable scope and autoglobals Variable scope and autoglobals.
Programming Epson Robots – Part 2 ME 4135 – Fall 2012 Dr. R. Lindeke.
Arrays and Control Structures CST 200 – JavaScript 2 –
CIS162AD - C# Decision Statements 04_decisions.ppt.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
1 Chapter 4: Selection Structures. In this chapter, you will learn about: – Selection criteria – The if-else statement – Nested if statements – The switch.
1 Session 3: Flow Control & Functions iNET Academy Open Source Web Programming.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
ITM 352 Flow-Control: if and switch. ITM © Port, KazmanFlow-Control - 2 What is "Flow of Control"? Flow of Control is the execution order of instructions.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
C# Programming Fundamentals Control Flow Jim Warren, COMPSCI 280 S Enterprise Software Development.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
PHP Constructs Advance Database Management Systems Lab no.3.
1 2. Program Construction in Java. 2.4 Selection (decisions)
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Computer Science: A Structured Programming Approach Using C1 5-2 Two-Way Selection The decision is described to the computer as a conditional statement.
Computer Science: A Structured Programming Approach Using C1 5-2 Two-Way Selection The decision is described to the computer as a conditional statement.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 7 Conditionals and Loops 4/18/09 Python Mini-Course: Day 2 - Lesson 7.
JavaScript, Fourth Edition
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
PEG200/Saidatul Rahah 1.  Selection Criteria › if..else statement › relational operators › logical operators  The if-then-else Statement  Nested if.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
CSCI 161 Lecture 7 Martin van Bommel. Control Statements Statements that affect the sequence of execution of other statements Normal is sequential May.
Chapter 3 Decisions Three control structures Algorithms Pseudocode Flowcharts If…then …else Nested if statements Code blocks { } multi statement blocks.
Class06 Conditional Statements MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/10/2015 © 2014,
8. DECISION STRUCTURES Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
COMP Loop Statements Yi Hong May 21, 2015.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.
JavaScript, Sixth Edition
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Chapter 3: Decisions and Loops
Sequence, Selection, Iteration The IF Statement
Class07 PHP: loops and includes
The order in which statements are executed is called the flow of control. Most of the time, a running program starts at the first programming statement,
CiS 260: App Dev I Chapter 4: Control Structures II.
Struktur Control : Decision
PHP Functions, Scope MIS 3501, Fall 2015 Jeremy Shafer
More Selections BIS1523 – Lecture 9.
Class07 PHP: loops MIS 3501 Jeremy Shafer Department of MIS
Selection Statements.
Objectives In this chapter, you will:
Loops and Arrays in JavaScript
statement. Another decision statement, , creates branches for multi-
Presentation transcript:

PHP Conditions MIS 3501, Fall 2014 Jeremy Shafer Department of MIS Fox School of Business Temple University September 11, 2014

1.A bit more information about HTML forms 2.Conditional statements in PHP 2 Two topics to cover today…

Create a “week3” folder under your web root, and a file called “loopdemo.php” inside it. Recreate any of one of the correct loops illustrated in the previous slides. Now edit and add additional echo statements to make a table, using the loop Finally, can you introduce a variable call $Max that will control how many times the loop iterates? So, if I set $Max = 100, I should get a table with 100 rows. 3 First … recall this exercise from last class

A little more about the tag See Discuss the tag attributes: action (Where to go) method (how to send data) method can be either GET or POST For now we are using GET Create a page called formdemo.php that sets the value of $Max in loopdemo.php 4

A little more about the tag See the formdemo.php page provided to you in week3.zip Note the use of the method and action What change do you need to make in loopdemo.php so that $Max changes with user input? 5

Making Decisions Decision making or flow control is the process of determining the order in which statements execute in a program The special types of PHP statements used for making decisions are called decision-making statements or decision-making structures

if Statements Used to execute specific programming code if the evaluation of a conditional expression returns a value of TRUE The syntax for a simple if statement is: if (conditional expression) { statement ; }

if Statements (continued) Contains three parts: –the keyword if –a conditional expression enclosed within parentheses –the executable statements A command block is a group of statements contained within a set of braces Each command block must have an opening brace ( { ) and a closing brace ( } )

if Statements (continued) $ExampleVar = 5; if ($ExampleVar === 5) { echo " The condition evaluates to true. "; echo " The variable is equal to ". $ExampleVar. " "); echo(" Each of these lines will be printed. "); } echo " This statement always executes after the if statement. ";

if...else Statements An if statement that includes an else clause is called an if...else statement An else clause executes when the condition in an if...else statement evaluates to FALSE The syntax for an if...else statement is: if (conditional expression) { statement; } else { statement; }

if...else Statements (continued) An if statement can be constructed without the else clause The else clause can only be used with an if statement $Today = " Tuesday " ; if ($Today === " Monday " ) { echo " Today is Monday “ ; } else { echo " Today is not Monday “ ; }

Nested if and if...else Statements When one decision-making statement is contained within another decision-making statement, they are referred to as nested decision-making structures if ($SalesTotal >= 50) { if ($SalesTotal <= 100) { echo " The sales total is between 50 and 100, inclusive. " ; }

Conditional Statements - Exercise Open up login.php See this php block at the top of the page: <?php if (isset($_GET[‘theSubmitButton'])) { echo "hello!"; } ?> Try it out. How does the page behave? What is the action tag set to. Why? What is isset doing? 13