gDI Camp PHP - PowerPoint PPT Presentation

Loading...

PPT – gDI Camp PHP PowerPoint presentation | free to view - id: 3130e-OGU5N



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

gDI Camp PHP

Description:

????????????????????????????????????????????????????? ... 'Sean Hannity' Other Operations. ALTER TABLE books ADD COLUMN subtitle varchar(50) AFTER title; ... – PowerPoint PPT presentation

Number of Views:147
Avg rating:3.0/5.0
Slides: 77
Provided by: song7
Category:
Tags: php | camp | gdi | hannity | sean

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: gDI Camp PHP


1
gDI CampPHP MySQL
???????? ???????? songrit_at_gmail.com 08-9182-5567
2
????? Web Services ???????????????????????????????
??????????? ???????? 1
3
??????????????????????
  • ??????????????????????????????????????????????????
    ???????????
  • ???????????????????????????????
  • ????????????? ???????????????????????? 10 ??
    ??????????????????????????????????????????????????

4
??????????????????????????
  • ??????????????????????????????????????????????????
    ????????????????
  • ???????????????????? Web Services
    ????????????????????

5
???????
  • ???????????????? Web Services ????????
    ?????????????
  • ????????????????????? (REST, SOAP)
  • ????????????????????????? (Open Source ????
    Commercial)
  • ????????????????????????????????? ?????????????
  • ??????????????
  • ???????????????????????????
  • ?????????????????????? ROI
  • ??????????????????????????????????????

6
????????
  • ??????????? ??????????????????  31 ??????? ??.
    2549
  • ???????????????? 1  ??????????????????????? 31
    ?????? ??. 2550
  • ?????????????????????????????? (?? Source Code
    ????????????????????????????????) ?????????? ??.
    2550
  • ???????????????????????? 2 ?????? ?????????? ??.
    2550 

7
??????
  • ????????? 1 ??????????? 50,000 ???
  • ????????? 2 ??????????? 30,000 ???
  • ????????? 3 ??????????? 20,000 ??? 

8
Web Architecture
Internet
Apache
PHP
MySQL
Data
pages
9
Lab 1 Installation
  • http//www.appservnetwork.com/

10
HTML
  • lthtmlgt
  • ltheadgt
  • lttitlegt My name is Songrit lt/titlegt
  • lt/headgt
  • ltbodygt
  • Hello, Class
  • lt/bodygt
  • lt/htmlgt

11
Tags
  • Link Tags
  • lta hrefhttp//www.cnn.com/gtCNN lt/agt
  • Image Tags
  • ltimg srchttp//www.x-rates.com/d/THB/USD/graph12
    0.pnggtExchange Ratelt/imggt
  • Markup tags
  • ltbgtThis text will be boldlt/bgt, ltigtitaliclt/igt,
  • and this is ltugtunderlinedlt/ugt

12
More tags
  • Heading tags
  • ltH1gtHead 1lt/H1gt
  • ltH2gtHead 2lt/H2gt
  • Paragraph tags
  • ltpgtThis is paragraph
  • ltpgtAnd this is another paragraph
  • Line Break tags
  • ltbrgtThis is paragraph
  • ltbrgtAnd this is another paragraph

13
HTML Editor
14
Lab 2 Your HTML
  • gdi.thaismall.com
  • A, IMG, B, I, P
  • http//gdi.thaismall.com/submit.php

15
List
  • ltulgt
  • ltligtFile
  • ltulgt
  • ltligtNewlt/ligt
  • ltligtOpenlt/ligt
  • lt/ulgtlt/ligt
  • ltligtEdit
  • lt/ulgt

16
Lab
  • lthtmlgt
  • ltheadgt
  • lttitlegtMenult/titlegt
  • lt/headgt
  • ltbodygt
  • lth1gtMy Menult/h1gt
  • lthr /gt
  • ltulgt
  • ltligtFile
  • ltulgt
  • ltligtNew
  • ltulgt
  • ltligtHTMLlt/ligt
  • ltligtCSSlt/ligt
  • lt/ulgtlt/ligt
  • ltligtOpenlt/ligt
  • lt/ulgtlt/ligt
  • ltligtEdit
  • ltulgt
  • ltligtCutlt/ligt
  • ltligtCopylt/ligt
  • lt/ulgtlt/ligt
  • ltligtViewlt/ligt
  • lt/ulgt
  • lthr /gt
  • lt/bodygt
  • lt/htmlgt

17
HTML DOM
18
  • C\Appserv\www\tree

19
Lab CSS
  • ltheadgt
  • lttitlegtMenult/titlegt
  • ltlink rel"stylesheet" type"text/css"
    media"all" hreftree/tree.css" /gt
  • ltscript type"text/javascript" srctree/tree.js"gt
    lt/scriptgt
  • lt/headgt
  • ltul class'tree'gt

20
Forms
  • Text Fields.
  • Password Fields.
  • Text Area.
  • Selectable lists.
  • Radio buttons.
  • Checkboxes.
  • File Fields
  • Hidden Field
  • Submit and Reset buttons.

21
Form Sample
  • ltHTMLgt
  • ltBODYgt ltFORM ACTIONaa.php" METHOD"post" gt
    User NameltINPUT TYPE"text" NAME "uname"
    SIZE30gt ltBRgt Service TypeltSELECT
    NAME"service"gt
  • ltOPTIONgtCASltOPTIONgtCDRS ltOPTIONgtCOPSATltOPTIONgtDD
    SltOPTIONgtFDSSlt/SELECTgt ltBRgt ltH4gtSUBJECT
    AREAlt/H4gt ltINPUT TYPE"checkbox"
    NAME"agriculture"gtAgriculture ltINPUT
    TYPE"checkbox" NAME"biology"gtBiology ltINPUT
    TYPE"checkbox" NAME"biomedicine"gtBiomedicine
    ltINPUT TYPE"checkbox" NAME"chemistry"gtChemistry
  • ltINPUT TYPEsubmit/gt
  • lt/formgt
  • lt/BODYgt
  • lt/HTMLgt

22
Lab 3 Form Page
  • Create Page that has Form

23
MSE to edit XML
24
Lab 4 Charts
  • http//www.maani.us/xml_charts/index.php

25
Lab 4 Charts HTML 1
ltHTMLgt ltheadgt lttitlegtXML/SWF Chartslt/titlegt lt/head
gt ltBODYgt ltOBJECT classid"clsidD27CDB6E-AE6D-11c
f-96B8-444553540000" codebase"http//download.ma
cromedia.com/pub/shockwave/cabs/flash/swflash.cab
version6,0,0,0" WIDTH"400" HEIGHT"320"
id"charts" ALIGN""gt ltPARAM NAMEmovie
VALUE"charts.swf?library_pathcharts_libraryxml_
sourcedata.xml"gt ltPARAM NAMEquality
VALUEhighgt ltPARAM NAMEbgcolor VALUE6666aagt
26
Lab 4 Charts HTML 2
  • ltEMBED src"charts.swf?library_pathcharts_library
    xml_sourcedata.xml"
  • qualityhigh
  • bgcolor6666aa
  • WIDTH"400"
  • HEIGHT"320"
  • NAME"charts"
  • ALIGN""
  • TYPE"application/x-shockwave-flash"
  • PLUGINSPAGE"http//www.macromedia.com/go/g
    etflashplayer"gt
  • lt/EMBEDgt
  • lt/OBJECTgt
  • lt/BODYgt
  • lt/HTMLgt

27
Lab 4 Chart XML 1
  • ltchartgt
  • ltchart_typegtcolumnlt/chart_typegt
  • ltchart_datagt
  • ltrowgt
  • ltnull/gt
  • ltstringgt2001lt/stringgt
  • ltstringgt2002lt/stringgt
  • ltstringgt2003lt/stringgt
  • ltstringgt2004lt/stringgt
  • lt/rowgt
  • ltrowgt
  • ltstringgt?????? ?lt/stringgt
  • ltnumbergt5lt/numbergt
  • ltnumbergt10lt/numbergt
  • ltnumbergt30lt/numbergt
  • ltnumbergt63lt/numbergt
  • lt/rowgt

28
Lab 4 Chart XML 2
  • ltrowgt
  • ltstringgt?????? ?lt/stringgt
  • ltnumbergt100lt/numbergt
  • ltnumbergt20lt/numbergt
  • ltnumbergt65lt/numbergt
  • ltnumbergt55lt/numbergt
  • lt/rowgt
  • ltrowgt
  • ltstringgt?????? ?lt/stringgt
  • ltnumbergt56lt/numbergt
  • ltnumbergt21lt/numbergt
  • ltnumbergt5lt/numbergt
  • ltnumbergt90lt/numbergt
  • lt/rowgt
  • lt/chart_datagt
  • ltlegend_label font'CordiaUPC' size'18'/gt
  • lt/chartgt

29
Lab 4 chart_type
  • line
  • bar
  • area
  • stacked 3d column
  • parallel 3d column
  • 3d pie
  • polar

30
PHP
  • Platform Independent
  • Windows
  • Linux
  • Mac
  • Sun
  • Web Server Independent
  • Support All Major Databases
  • Free and Open Source

31
The PHP Model
ltHTMLgtlt?PHP echo(Hello World!)?gtlt/HTMLgt Bec
omes ltHTMLgtHello World!lt/HTMLgt
32
Lab5.php
  • lthtmlgt
  • ltbodygt
  • ltstronggtHello World!lt/stronggtltbr /gt
  • lt?
  • echo Today is
  • echo date(Hi jS F)
  • ?gt
  • lt/bodygt
  • lt/htmlgt

33
Window Explorer
  • Tools gt Folder Options
  • View gt uncheck Hide extension for known file
    types

34
PHP Example 2a
  • ltform actionnext.php" methodget"gt
  • ltinput type"submit" name"submit"
    value"Submit"gt
  • ltinput type"submit" name"cancel"
    value"Cancel"gt
  • lt/formgt

35
PHP Example 2b
  • lt?php
  • if (_GET"submit")
  • echo "lth2gtYou clicked Submit!lt/h2gt"
  • else if (_GET"cancel")
  • echo "lth2gtYou clicked Cancel!lt/h2gt"
  • ?gt

36
PHP Example 3
  • ltform actionnext.php" methodpost"gt
  • ltinput type"submit" name"submit"
    value"Submit"gt
  • ltinput type"submit" name"cancel"
    value"Cancel"gt
  • lt/formgt

37
Variable
  • foo bar Data Type String
  • foo 1 Data Type integer
  • foo 5.34 Data Type Double
  • foo array(bar,united) Data Type Array

38
Form Variables
HTML
PHP
  • ltFORM actionaa.phpgt
  • Var1 ltINPUT NAMEvar1 TYPEtextgt
  • Var2 ltINPUT NAMEvar2 TYPEtextgt
  • lt/FORMgt
  • _POSTvar1
  • _GETvar2

39
Operators
  • Assignment (e.g. , , )
  • a a1 gt a 1
  • Arithmetic (e.g. , -, )
  • Comparison (e.g. lt, gt, gt, )
  • Logical (e.g. !, , )

40
If
  • if (foo 0)
  • echo The variable foo is equal to 0
  • else if ((foo gt 0) (foo lt 5))
  • echo The variable foo is between 1 and 5
  • else
  • echo The variable foo is equal to .foo

41
Indexed Array
  • marks array (95, 93, 56, 70, 65, 98)
  • marks0 95
  • marks1 93
  • marks2 56
  • marks3 70
  • marks4 65
  • marks5 98

42
Associative Array
  • marks array ("Adrian"gt93, "Lance"gt56,
    "Stephen"gt70, "Craig"gt65, "Andy"gt98)

43
Lab Associative Array
  • lt?
  • marks array ("Adrian"gt93, "Lance"gt56,
    "Stephen"gt70, "Craig"gt65, "Andy"gt98)
  • reset(marks) // go to the beginning of the
    array
  • echo lttable border1gt
  • while (list(key, value) each(marks))
  • echo "lttrgtlttdgtkeylt/tdgtlttdgtvaluelt/tdgtlt/trgt\n"
  • echo "lt/tablegtlthrgt"
  • ?gt

44
Control Flow
  • if (expr1)
  • elseif (expr2)
  • else
  • while (cond)
  • do while (cond)
  • switch (var)
  • case a
  • case b
  • for (i 0 i lt expr i )
  • foreach (array_expr as value)
  • foreach (array_expr as keygtvalue)
  • break
  • continue

45
Function
  • lt?
  • function add (a1, a2)
  • return a1a2
  • echo add(2,2)
  • ?gt

46
File_get_contents
  • lt?
  • localfile file_get_contents("abc.txt")
  • httpfile file_get_contents("http//www.cnn.com"
    )
  • ftpfile file_get_contents("ftp//userpass_at_ftp.
    example.com/abc.txt")
  • ?gt

47
Lab 5
  • File_get_contents(http//news.sanook.com/lotto/lo
    tto_43824.php)

48
Lab 7 make XML
  • lt?xml version1.0?gt
  • ltLottery roundMmm dd, yyyygt
  • ltFirstPrizegtmmmmmmlt/FirstPrizegt
  • ltThreeDigitgtmmmlt/ThreeDigitgt
  • ltThreeDigitgtmmmlt/ThreeDigitgt
  • ltThreeDigitgtmmmlt/ThreeDigitgt
  • ltThreeDigitgtmmmlt/ThreeDigitgt
  • ltTwoDigitgtmmmlt/TwoDigitgt
  • lt/Lotterygt

49
Lab 8
  • Print 4 three digits winning using simplexml

50
Lab Solution
  • lt?
  • http file_get_contents(http//localhost/lottery
    .php')
  • xml simplexml_load_string(http)
  • for (i0 ilt4 i)
  • echo "ltpgtThree Digit i ".xml-gtThreeDigiti
  • ?gt

51
Lab 9 Geocoder
  • http//brainoff.com/geocoder/rest/
  • http//brainoff.com/geocoder/rest/?cityBangkok,TH
  • http//brainoff.com/geocoder/rest/?cityNonthaburi
    ,TH
  • http//brainoff.com/geocoder/rest/?cityChiengmai,
    TH

52
Test 1
  • http//192.168.0.xxx3006/test

53
MySQL
  • CREATE TABLE books ( idNumber int primary key
    auto_increment, title varchar(30), author
    varchar(30))

54
MySQL
  • INSERT INTO books (title,author) VALUES( Let
    Freedom Ring, Sean Hannity)

55
Other Operations
  • ALTER TABLE books ADD COLUMN subtitle varchar(50)
    AFTER title
  • UPDATE books SET subtitleWinning the War of
    Liberty over Liberalism WHERE idNumber1
  • SELECT FROM books
  • DELETE FROM books

56
  • lt?
  • db mysql_connect("localhost","root","")
  • result mysql_select_db("gdi2", db)
  • result mysql_query("INSERT INTO
    members(fname,lname,email) VALUES('fff', 'ddd',
    'eee')", db)
  • ?gt

57
Use MySQL in PHP (1)
  • lt?
  • db mysql_connect("localhost",user",password
    ")
  • or die(Couldn't connect to database.")
  • result mysql_select_db(dbname", db)
  • or die(Couldn't select database.")
  • sql SELECT username, email FROM contact
  • result mysql_query(sql, db)
  • or die(Something is wrong with your SQL
    statement.")

58
Use MySQL in PHP (2)
  • while (rowmysql_fetch_array(result))
  • username rowusername
  • email rowemail
  • echo lta href mailto.email.gt.username.lt
    /agtltbr /gt\n
  • ?gt

59
PHPMySQLHTML
  • lt?php
  • dbLink mysql_connect("localhost", dbUser,
  • dbPass)
  • sql "SELECT FROM books"
  • res mysql_db_query("test", sql, dbLink)
  • row mysql_fetch_assoc(res)
  • title row"title"
  • subtitle row"subtitle"
  • author row"author"
  • ?gt
  • lttable border"1"gtlttrgt
  • lttdgtltbgtTitlelt/bgtlt/tdgtlttdgtltbgtSub
    Titlelt/bgtlt/tdgtlttdgtltbgtAuthorlt/bgtlt/tdgtlt/trgt
  • lttrgtlt?php echo "lttdgttitlelt/tdgtlttdgtsubtitlelt/tdgtlt
    tdgtauthorlt/tdgt"?gt
  • lt/trgtlt/tablegt

60
Lab 10 PhpMyAdmin
  • Create table members
  • id (autoincrement)
  • fname
  • lname
  • email
  • Export table

61
Download
  • http//192.168.0.xxx3006/download/index.html
  • SQLYog

62
Lab 11 PHP App
  • Member Registration
  • register.php
  • edit.php
  • thankyou.php
  • list.php

63
Lab 12 Search
  • search.php?usernamexxx
  • return HTML Table
  • return XML
  • lt?xml version"1.0" encoding"UTF-8" ?gt

64
Lab 13 Province
  • Use PhpMyAdmin to inspect province db
  • province.php?idxx
  • region.php?idxx
  • Output as XML

65
Template
  • Presentation
  • Logic

http//www.tinybutstrong.com/
66
lab1list.php
  • lt?
  • include_once('tbs.php')
  • include('db.inc')
  • TBS new clsTinyButStrong
  • TBS-gtLoadTemplate('lab1list.tbs')
  • sql'SELECT FROM lab1'
  • TBS-gtMergeBlock('n',db,sql)
  • TBS-gtShow()
  • ?gt

67
lab1list.tbs
  • lttable aligncentergt
  • lttrgtltthgtnamelt/thgtltthgtHTMLlt/thgtlt/trgt
  • lttrgtlttd aligncentergt
  • n.unamehtmlconvnoblocktr
  • lt/tdgtlttdgtlta href'lab1/n.html'gt
  • n.htmllt/agtlt/tdgtlt/trgt
  • lt/tablegt

68
Lab 14 using TBS
  • province.php?idxx
  • region.php?idxx
  • Output as XML

69
  • Japan in 1993
  • OOP
  • Combines
  • Smalltalk
  • Python
  • Perl
  • General Public License

70
  • Open source Ruby framework
  • Faster development
  • Fewer bugs
  • Convention over configuration

71
Download
  • http//192.168.0.xxx3006/download/index.html
  • InstantRails

72
win-R gt cmd
  • rails gdi
  • cd gdi
  • ruby script\server
  • http//localhost3000

73
Directory Structure
  • app
  • model
  • view
  • controller
  • config
  • public
  • images
  • stylesheets

74
main
  • ruby script\generate controller main
  • def index
  • render text gt "Hello, World"
  • end

75
Lab 11 Revisit
  • Member Registration
  • register
  • Username
  • Full name
  • Email
  • update
  • thankyou
  • list

76
Model
  • ruby script\generate model Member
  • scaffold
About PowerShow.com