PHP ARRAY AND HTML TABLE IST 210 Organization of Data IST210 1.

Slides:



Advertisements
Similar presentations
» PHP arrays are lists of values stored in key-value pairs. » Uses of arrays: Many built-in PHP environment variables. Database functions use arrays.
Advertisements

Internet Applications Development Lecture 2 L. Obead Alhadreti.
Intro To Cascading Style Sheets By Mario Yannakakis.
Cascading Style Sheets
CHAPTER 8 ADVANCED CSS. LEARNING OBJECTIVES Assign formatting styles to a CSS class definition Use a tag’s class attribute to apply the styles defined.
Chapter 7: Introduction to Debugging TECH Prof. Jeff Cheng.
HTML Form and PHP IST Review of Previous Class HTML table and PHP array Winner is chosen automatically using rand() function.
IST 221 Internet Concepts and Applications Introduction to PHP.
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.
JMD2144 – Lesson 5 Web Design & New Media. ‘Div’ide and conquer One of the most versatile structure tags available is the.. tag Short for ision, it allows.
HTML. We’ll learn … What HTML is What tags are What a basic web page looks like What 3 HTML tags are required What HTML comments look like How to title.
THE BACKBONE OF EVERY WEB PAGE HTML Day 1. What will we learn? How to create a basic web page Backgrounds and colors How to link Web sites How to include.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
ACM 511 HTML Week -1 ACM 511 Course Notes. Books ACM 511 Course Notes.
1 Essential HTML coding By Fadi Safieddine (Week 2)
Lecture # 3 HTML and Arrays. Today Questions: From notes/reading/life? From Lab # 2 – Preview of Lab # 2 1.Introduce: How do you make a Web Page?: HTML.
More Basic HTML. Add spacing (single & double space) Save Refresh Add horizontal rule Add comments Add styles Add headings Add features Add alignments.
15.2 More Basic HTML. More Basic HTML Add spacing (single & double space) Save Refresh Add horizontal rule Add comments Add styles Add headings Add features.
Introduction to HTML. HTML Hyper Text Markup Language Page Title My First Heading My first paragraph. Page Title My First Heading My first paragraph.
CHAPTER 1 HTML & HTML5 I อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
HTML Basic I IST2101. Keep In Mind Programming can be time consuming. Plan ahead!
HTML CRASH COURSE. What is HTML?  Hyper Text Markup Language  The language used to make web pages  Written by using tags.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Just A Few More Fun Objectives 1 Having Some Fun With Java Script 2 Using Style Sheets.
How are tables used in web design?. A table (FIVE THINGS TO KNOW) 1. Is made up of columns and rows 2. Has cells where columns and rows intersect.
G053 Lecture 12 Introduction To HTML Mr C Johnston ICT Teacher
HTML Hyper Text Markup Language. What is an HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
HTML Basic IST2101. Keep In Mind Programming can be time consuming. Plan ahead!
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.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
HTML— More Tags, Formatting, and Lists. Formatting Tags  Bold  Italics  Underline  Big text  Small text  Subscript (H 2 O)  Superscript (10 3 )
A LOTTERY GAME Assignment P2 IST Guideline Use the PHP you learnt in class to make a PHP page Game rules:
Introduction to HTML : Hyper Text Markup Language.
Web Design Mr. Briggs’ Classes September 6-7, 2011.
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.
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.
U:/msu/course/cse/103 Day 21, Slide 1 CSE 103 Makeups –If you didn’t take one over the weekend, take one TUESDAY or WEDNESDAY!
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Cascading Style Sheets
HTML BASIC IST 210: Organization of Data IST210 1.
Spiderman ©Marvel Comics Creating Web Pages (part 1)
WEEK -1 ACM 262 ACM 262 Course Notes. HTML What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML.
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.
CPSC 217 T03 Week V Part #1: Iteration Hubert (Sathaporn) Hu.
HTML HYPER TEXT MARKUP LANGUAGE. INTRODUCTION Normal text” surrounded by bracketed tags that tell browsers how to display web pages Pages end with “.htm”
What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML is not a programming language, it is a markup.
Getting Started with HTML. HTML  Hyper Text Markup Language  HTML isn’t a program language, its known as a markup language  A Markup language has tags.
PHP (cont.). 2 Functions Definition – function name(arguments){... } –syntax name as for a variable, but without $ arguments as for variables –to return.
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
HTML HTML stands for Hyper Text Markup Language. HTML is used in making the base of a Website You can just use an online website maker like weebly.com.
HTML Tags BTT1O. HTML  Documents written in hypertext markup language can be interpreted by all web browsers.  This language lets the web page developer.
HTML FORM AND PHP IST 210: Organization of Data IST210 1.
PHP AND SQL SERVER: QUERIES IST 210: Organization of Data IST210 1.
HTML. Hyper Text Markup Language Markup your text document The markup is the tag Hyper text means you can jump from place to place Programming language.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
PHP Array and HTML Table IST 210 Organization of Data IST2101.
1 R3 R1 R5 R4 R6 R2 B B A A Looking at the Code Under the View menu Select Source.
HTML Basic IST 210: Organization of Data IST2101.
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
G053 Lecture 12 Introduction To HTML Mr C Johnston ICT Teacher
HTML Introduction. Lecture 7 What we will cover…  Understanding the first html code…  Tags o two-sided tags o one-sided tags  Block level elements.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
HTML Lesson 2.
Intro to PHP & Variables
HTML.
Presentation transcript:

PHP ARRAY AND HTML TABLE IST 210 Organization of Data IST210 1

2 1. Title should be your name 2. Background has color yellow 3. Welcome line in heading 4. Your name in bold 5. Major in color red 6. Year in font Arial 7. Hobby in color blue, font Arial, and italic 8. Access it from the web

IST210 3 Heading 1 Font of the number: color red, size 5 Font of the number: color green, size 5 Font: color green in heading 1,2,3 Repeat 3 times (because your number is the same as the lucky number- you win- and 3 is the your random number)

Tips in Debugging What’s wrong with my code? IST210 4

Tips in Debugging Identify errors by systematically commenting out and running parts of your code Use // to comment out a line Use /* and */ to comment out a segment of codes IST210 5

6 Bug! When we don’t comment out this line! echo "Your number is $y ";

Learn to Debug Bad question “What’s wrong with my code?” “I have no clue why it is not working” You need to identify the specific location and/or the specific problem in your code, and then ask questions like “Am I using the dots and quotation marks in this echo command correctly?” “Can you explain to me what’s the difference between A==B and A=B?” Know how to debug is a very important skill ! Totally ok to make mistakes when coding You are encouraged to make mistakes! But you need to know where is the mistake, how to fix it, and how to avoid making the same mistake again.  that’s how you gradually become an expert in programming (a.k.a, geek) IST210 7

HTML Table Tables Format data in a way that can be easily comprehended Elements Table Headings Rows Data IST210 8

An Example of HTML Table Firstname Lastname John Smith Anthony Kim IST210 9 Try it Tables are defined with the tag. Tables are divided into table rows with the tag. Table rows are divided into table data with the tag. A table row can also be divided into table headings with the tag.

An Example of HTML Table Firstname Lastname John Smith Anthony Kim IST Try it Step 1. Open a NotePad++ Step 2. Input codes Step 3. Save it to “table.html” to your webspace Step 4. Open a web browser, and visit

PHP Array Array is a data structure that allows you to manage a list of data easily. Color list: red, yellow, blue It is not efficient to use a variable to represent each value. $color1= "red"; $color2 = "yellow"; $color3 = "blue"; IST210 11

Use Array in PHP Color list {"red", "yellow", "blue”}; $color[0] = "red"; $color[1] = "yellow"; $color[2] = "blue"; IST Key Array name Like C/C++, PHP uses 0-based numbering

Use Array in PHP IST <?php $color[0] = "red"; $color[1] = "yellow"; $color[2] = "blue"; echo $color[0]." "; echo $color[1]." "; echo " $color[2] "." "; ?> Try it PHP is a very flexible language. When accessing arrays by offset, you can actually use two different types of syntax: the [] syntax we've covered, or you can use curly braces ({}) color.php

Using For Loop to Retrieve Array Values IST <?php $color[0] = "red"; $color[1] = "yellow"; $color[2] = "blue"; for ($i=0; $i<3; $i++) { echo $color[$i]." "; } ?>

Modify array elements IST <?php $color[0] = "red"; $color[1] = "yellow"; $color[2] = "blue"; $color[1] = "green"; for ($i=0; $i<3; $i++) { echo $color[$i]." "; } ?> Try it

Using Foreach Loop to Retrieve Array Values IST No need to know the length of the array <?php $color[0] = "red"; $color[1] = "yellow"; $color[2] = "blue"; foreach ($color as $currentcolor) { echo $currentcolor." "; } ?> Try it You can think of foreach as jumping from element to element in the array and running the code between {}s for each of those elements For each thing in $color, assign that thing temporarily to the variable $currentcolor. No need to use the name $color. Just as for loop, we can name our temporary variable anything we want

Initialization of Array IST $color[0] = "red"; $color[1] = "yellow"; $color[2] = "blue"; $color = array("red", "yellow", "blue"); <?php $color = array("red", "yellow", "blue"); foreach ($color as $currentcolor) { echo $currentcolor. " "; } ?> Try it Start with index 0 $color[0] = “red”

Use PHP Array to Control HTML Font IST <?php $color[0] = "red"; $color[1] = "yellow"; $color[2] = "blue"; foreach ($color as $currentcolor) { echo " ".$currentcolor." "; } ?> Try it

Use PHP Array to Generate a HTML Table (Important!) Firstname Lastname John Smith Anthony Kim IST <?php echo " Name Table "; $lastname = array('Smith', 'Kim', 'Davis'); $firstname = array('John', 'Anthony', 'Richard'); echo " "; echo " Lastname "; echo " Firstname "; echo " "; for ($i=0; $i<count($lastname); $i++) { echo " "; echo " $lastname[$i] "; echo " $firstname[$i] "; echo " "; } ?> Try it PHP (dynamic) HTML (Static)

More Examples on Loop and Array For loop Foreach loop While loop Array IST210 20

Reminder Assignment P3 due on next Wednesday 11:59PM (Oct 28) Report 2 and Assignment 4 due today Visit the project page on our website: IST210 21