PHPMySQL_CH02.ppt

download PHPMySQL_CH02.ppt

of 21

Transcript of PHPMySQL_CH02.ppt

  • 7/25/2019 PHPMySQL_CH02.ppt

    1/21

    LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    PHP and MySQL for

    Dynamic Web Sites 4th Edition

    Instructors NotesChapter 2: Programming with PHP

    Copyright 2012 by Larry Uman

  • 7/25/2019 PHPMySQL_CH02.ppt

    2/21

    LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Leanin O"t#o$e%

    ! I"enti#y how $ey pieces o# an H%&L #orm reate to PHP

    ! Choose the proper H%&L #orm metho"

    ! Han"e H%&L #orm "ata in a PHP script! Use common con"itionas

    ! 'ecogni(e an" use the stan"ar" operators

    ! )ai"ate #orm "ata in se*era ways

  • 7/25/2019 PHPMySQL_CH02.ppt

    3/21

    LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Leanin O"t#o$e%

    ! I"enti#y what arrays are

    ! 'ecogni(e the supergoba arrays

    ! Create arrays using "i##erent approaches! +ccess e*ery eement in an array

    ! ,ort arrays

    ! Con*ert between arrays an" strings

    ! Use oops

  • 7/25/2019 PHPMySQL_CH02.ppt

    4/21

    LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    An HT&L 'o$

    Name:

    Email !!ress:

    #en!er: %ale &emale

    ge:

    omments:

  • 7/25/2019 PHPMySQL_CH02.ppt

    5/21

    LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Choo%in a &ethod

    GET

    ! %he stan"ar" metho" #ora ser*er re-uests

    ! .ata appen"e" to theU'L

    ! Can be boo$mar$e"

    ! User can cic$ /ac$

    ! Use" #or re-uestingin#ormation

    POST

    ! .ata is not *isibe in theU'L

    ! &uch arger imit on theamount o# "ata that canbe submitte"

    ! Can sen" #ies

    ! Users see warnings i#they cic$ /ac$

    ! Use" #or re-uesting action

  • 7/25/2019 PHPMySQL_CH02.ppt

    6/21

    LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Hand(in a 'o$

    ! Use '3U,%45name56

    ! 7r use 8%45name56 an" P7,%45name569"epen"ing upon the #orms metho" *aue

    ! +ways oa" the #orm through a U'L

  • 7/25/2019 PHPMySQL_CH02.ppt

    7/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Hand(in a 'o$

  • 7/25/2019 PHPMySQL_CH02.ppt

    8/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Co$$on Po)(e$%

    ! ;aiure to oa" the #orm through a U'L

    ! Incorrect re#erence to the PHP script

    ! Case?sensiti*ity issue with PHP *ariabes

    ! Incorrect eement names in the H%&L #orm

  • 7/25/2019 PHPMySQL_CH02.ppt

    9/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Conditiona(%

    i# @

    AA .o this

    Bi# @

    AA .o this

    B ese @

    AA .o thatB

    i# @

    AA .o this

    B esei# @AA .o that

    B ese @

    AA .o whate*er

    B

  • 7/25/2019 PHPMySQL_CH02.ppt

    10/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    What i% t"e*

    ! *ar9 i# *ar has a *aue other than 09 an emptystring9 ;+L,9 or NULL

    ! isset9 i# *ar has any *aue other than NULL9incu"ing 09 ;+L,9 or an empty string

    ! %'U9 true9 %rue9 etc=

  • 7/25/2019 PHPMySQL_CH02.ppt

    11/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    O+eato%Symbol Meaning Type

    is e-ua to comparison

    is not e-ua to comparison

    D ess than comparison

    E greater than comparison

    D ess than or e-ua to comparison

    E greater than or e-ua to comparison

    not ogica

    FF an" ogica+N. an" ogica

    GG or ogica

    7' or ogica

    7' an" not ogica

  • 7/25/2019 PHPMySQL_CH02.ppt

    12/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Va(idatin 'o$ Data

    ! Ne*er trust eterna "ata

    ! Use isset to con#irm *ariabe has a *aue

    ! Use empty to con#irm *ariabe has a non?empty*aue

    ! Chec$ the "atas type9 when appropriate9 #oreampe9 using isnumeric

    ! Chec$ the "atas *aue9 when appropriate=

  • 7/25/2019 PHPMySQL_CH02.ppt

    13/21

  • 7/25/2019 PHPMySQL_CH02.ppt

    14/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    A##e%%in Aa,%

    // *se array notation to a''ess in!i$i!ual elements:

    7ban! = 7artists;0

    e'ho 7states;%

    // Fou 'anGt !o this:

    e'ho "%y list of states: 7states"

    // r this:

    e'ho "H is 7states;H5" // ,I

  • 7/25/2019 PHPMySQL_CH02.ppt

    15/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    S"+e(o)a( Aa,%

    ! 8%

    ! P7,%

    ! '3U,%! ,')'

    ! N)

    ! ,,,I7N

    ! C77JI

  • 7/25/2019 PHPMySQL_CH02.ppt

    16/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Ceatin Aa,%

    7ban!; = Jemaine

    7ban!; = ,ret

    7ban!; = %urray

    7ban!;fan = %el7ban!;fan = a$e // Ne- $alue

    7fruit;2 = apple

    7fruit;2 = orange // Ne- $alue

    7states = array K

    => o-aA

    % => %arylan!L

    7artists = array Klem 1ni!eA 1hinsA EelsL

  • 7/25/2019 PHPMySQL_CH02.ppt

    17/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Loo+in Tho"h Aa,%

    forea'h K7array as 7$alueL M

    // o something -ith 7$alue5

    // r:

    forea'h K7array as 7@ey => 7$alueL M

    e'ho "he $alue at 7@ey is 7$alue5"

  • 7/25/2019 PHPMySQL_CH02.ppt

    18/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Sotin Aa,%

    ! sort9 by *aue9 "ropping the $eys

    ! asort9 by *aue9 maintaining the $eys

    ! $sort9 by $ey9 maintaining the *aues! rsort9 sort in re*erse or"er

    ! arsort9 asort in re*erse or"er

    ! $rsort9 $sort in re*erse or"er

    VISUAL QUICKPRO GUIDE

  • 7/25/2019 PHPMySQL_CH02.ppt

    19/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Aa,% and Stin%

    7array = explo!e KseparatorA 7stringL

    7string = implo!e KglueA 7arrayL

    7sO = %on(ue(Be!(hu(&ri7!ays6array = explo!e K(A 7sOL

    // 7!ays6array no- a fi$e(element arrayA -ith %on in!exe! at 05

    7s2 = implo!e KA A 7!ays6arrayL

    // 7s2 no- a 'omma(separate! list of !ays: %onA ueA Be!A huA &ri5

    VISUAL QUICKPRO GUIDE

  • 7/25/2019 PHPMySQL_CH02.ppt

    20/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    Whi(e Loo+%

    -hile KconditionL M

    // o something5

    VISUAL QUICKPRO GUIDE

  • 7/25/2019 PHPMySQL_CH02.ppt

    21/21LEARN THE QUICK AND EASY WAY!

    VISUAL QUICKPROGUIDE

    'o Loo+%

    for Kinitial expression condition closing expressionL M

    // o something5

    for K7i = O 7i