Exercise 1: IF/ELSE Step 1: Open NotePad++ and create “number.php” in your webspace Step 2: Write codes to do the following 1.Generate a random number.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Using GET data within a IF Statement. If ($GETCom === ‘home’) { echo ’They Match’; } $GETCom = $_GET[‘com’]; If the data stored in the variable ($GETCom)
Factors Objective – To be able to find all the factors of a given integer.
Introduction to Flowcharting
HTML Form and PHP IST Review of Previous Class HTML table and PHP array Winner is chosen automatically using rand() function.
PHP Conditions MIS 3501, Fall 2014 Jeremy Shafer Department of MIS Fox School of Business Temple University September 11, 2014.
Matlab tutorial course Exercises 4:. Exercises – for loops Download the scripts loops_example.m and if_else_example.m, run the code Download the function,
IST 221 Internet Concepts and Applications Introduction to PHP.
Building Java Programs
The If/Else Statement, Boolean Flags, and Menus Page 180
PHP and SQL Server: Queries IST2101. Three-Tier Architecture Three-tier architecture means that the Web server and the DBMS are on separate servers IST2102.
PHP and SQL Server: Queries IST2101. Project Report 4 SQL Queries Due Sunday, 4/5 at 11:59pm Instructions on how to access team webspace and SQL database.
VAVLPVCTYMAUS PSABLADDERZSB EBSANTESHTICL RLDUDSKTTVSRA EDEARCENEAUOD CRFNORSASINTD TPEUUOCPTDATP UNRTMTRBEEXME MIEUSUULSNSNN USNMEMNISAIIT AESXSVPENNISI.
CS1101: Programming Methodology Aaron Tan.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
QPLNHTURBIOTS CADAIASOINCOS OSTPOSTLGVAGT AJRLFKLEROUEA CLARITYSOLSTB HTEAMVSRUVAHI INTERACTPELEL NAPKSOCIALIRI GSOCIOGRAMTST CONFORMITYYTY 14 WORDS ANSWERS.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
SIMPLE ROUTER The slide made by Salim Malakouti. Next we will create the Router  What do I we mean by a router?  Routers work similar to a map. It receives.
Loop Exercise 1 Suppose that you want to take out a loan for $10,000, with 18% APR, and you're willing to make payments of $1,200/month. How long will.
THE BIG PICTURE. How does JavaScript interact with the browser?
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CONTROL STRUCTURE The if, elseif, and else & switch Statements 1.
How to start Visual Studio 2008 or 2010 (command-line program)
HTML Table and PHP Array
PHP Logic. Review: Variables Variables: a symbol or name that stands for a value – Data types ( Similar to C++ or Java): Int, Float, Boolean, String,
HTML Form and PHP IST Review of Previous Class HTML table and PHP array Winner is chosen randomly using rand() function.
Programming Assignment 3 Add forms in your web page so that visitors can add a comment about your web page – Example:
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
Linear Data Structures LIFO – Polish notation Context Saving.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Algorithms Writing instructions in the order they should execute.
A LOTTERY GAME Assignment P2 IST Guideline Use the PHP you learnt in class to make a PHP page Game rules:
Notes Over 2.8 Rules for Dividing Negative Numbers. ( Same as Multiplying ) If there is an even number of negative numbers, then the answer is Positive.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Warm Up no 0, 3 x = -3. Homework Questions Section 2.2 Synthetic Division; The Remainder and Factor Theorems Objective: To use synthetic division and.
PHP and SQL Server: Connection IST2101. Typical web application interaction (php, jsp…) database drivers 2IST210.
PHP and SQL Server: Queries IST2101. Steps to Design PHP Pages to Answer User Queries 1.Query generation – What SQL query do we need to retrieve the desired.
Multiply Positive and Negative Numbers August 26, 2015.
Mr. Hudson’s Review Test on Thursday. Topics Arrays Traversing Loops Selections Identifying code throughout a program Type Casting Conversion of numbers.
CST336, Dr. Krzysztof Pietroszek Week 2: PHP. 1.Introduction to PHP 2.Embed PHP code into an HTML web page 3.Generate (output HTML) web page using PHP.
PHP Variables.  Variables are "containers" for storing information. How to Declare PHP Variables  In PHP, a variable starts with the $ sign, followed.
 A PHP script can be placed anywhere in the document.  A PHP script starts with  The default file extension for PHP files is ".php".  A PHP file normally.
Divisibility Tests How can you tell quickly whether a number can be divided exactly by another?
1 Introduction to Flowcharting Computer Science Principles ASFA.
Computer Science I: Understand how to evaluate expressions with DIV and MOD Random Numbers Reading random code Writing random code Odds/evens/…
R Workshop #2 Basic Data Analysis. What we did last week: Understand the basics of how R works Generated objects (vectors, matrices, etc.) Read in data.
HTML FORM Lab Exercise IST Guideline Add forms in your web page so that visitors can add a comment about your web page Forms should include the.
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.
Engineering Computing I Chapter 3 Control Flow. Chapter 3 - Control Flow The control-flow of a language specify the order in which computations are performed.
HTML FORM AND PHP IST 210: Organization of Data IST210 1.
PHP ARRAY AND HTML TABLE IST 210 Organization of Data IST210 1.
PHP AND SQL SERVER: QUERIES IST 210: Organization of Data IST210 1.
Repetition Looping. Types for while do..while for The for loop allows you to iterate through a variable for a specific range of values. You must supply.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
PHP Array and HTML Table IST 210 Organization of Data IST2101.
DATABASE ACCESS CONTROL IST Question Almost every PHP page needs to interact with database, does that mean sqlUsername and sqlPassword need to be.
Objective of the lesson Use Blockly to make a dice for Snakes and Ladders All of you will: – Make an image which displays when you press a button Most.
 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.
First Steps in PHP Creating Very Simple PHP Scripts SoftUni Team Technical Trainers Software University
2.3 Output Formatting. Outputting Format Specify the number of spaces, “c”, used to print an integer value with specifier %cd, e.g., %3d, %4d. E.g. printf.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
Programming Assignment 4: HTML Table and PHP Array.
3x + 2 6x3 - 5x2 – 12x – 4 2x2 – 3x – 2 6x3 + 4x2 -9x2 – 12x -9x2 – 6x
Creating Variables Output Logic flow Operators (More) Basic blocks
Learning Outcomes –Lesson 4
Understanding Code Workshop 2.
Exam # 1 INFORMATION Scheduled for Thursday 7/20
Presentation transcript:

Exercise 1: IF/ELSE Step 1: Open NotePad++ and create “number.php” in your webspace Step 2: Write codes to do the following 1.Generate a random number x in [1,10] and display it Hint 1: Use rand(1,10) to generate a random number in [1,10] Hint 2: Use variable $x to store the rand number Hint 3: Use echo to output the variables 2.Determine whether x is an odd number or an even number, and display the result Hint: Use the expression $x % 2 to find the remainder of $x divided by 2. IST2101

Exercise 1 answer A Simple PHP Page <?php $x = rand(1,10); echo "The random number is: $x "; if ($x % 2 == 0) echo "It is an even number "; else echo "It is an odd number "; ?>

Exercise 2: Loop Use Loop to display “I love Penn State” in increasing font size (from 2 to 6) Font size 2 Font size 6

Exercise 2 answer <?php for ($i=2; $i<=6; $i++) { echo " I love Penn State! "; } ?>