Introduc)on	
  to	
  PHP	
  


TCNJ	
  –	
  Web	
  Design	
  2	
  :	
  Dynamic	
  

                By	
  Jean	
  Ho	
  Chu	
  
                Week	
  01.	
  Jan	
  19.	
  2012	
  
What	
  is	
  Dynamic	
  Website?	
  

Dynamic	
  Website	
                                                    Sta/c	
  Website	
  
•    ASP.NET,	
  JSP,	
  Ruby	
  on	
  rail,	
  PHP,	
  etc	
  	
       •    HTML,	
  Javascript,	
  etc	
  
•    Scrip)ng	
  language	
                                             •    Compiled	
  language	
  	
  
•    Generates	
  the	
  code	
  for	
  the	
  site	
                   •    Only	
  displays	
  pages	
  
•    Acts	
  on	
  the	
  server,	
  lives	
  on	
  the	
  server	
     •    Acts,	
  lives	
  anywhere	
  clients	
  are	
  
•    Server	
  Side	
  Programming	
                                    •    Client	
  Side	
  Programming	
  
•    Back	
  End	
  Development	
                                       •    Front	
  End	
  Development	
  

•  Has	
  memories	
                                                    •  No	
  memories	
  
•  Responsive,	
  malleable	
                                           •  Not	
  responsive	
  

•  More	
  difficult	
  to	
  develop	
  the	
  ini)al	
                  •  Quick	
  and	
  cheap	
  to	
  develop	
  the	
  ini)al	
  
   website	
                                                               website	
  
This	
  is	
  Sta)c	
  HTML	
  Website…	
  
This	
  is	
  Dynamic	
  Website	
  !	
  

                                                                                           Fast,	
  Clean,	
  Easy	
  
  Molds	
  &	
  Frames	
                              Contents	
                           Diverse	
  results!	
  




                                      +	
                                         =	
  
Server	
  side	
  code	
  provides	
  	
      Contents	
  are	
                           The	
  html	
  page	
  of	
  	
  
templates	
                                   provided	
  by	
  users	
  or	
             what	
  the	
  users	
  see	
  is	
  
from	
  the	
  server	
                       from	
  databases	
                         	
  generated!	
  
What	
  is	
  Client	
  ?	
  Server?	
  

Client	
                          Server	
  
•  Visible	
  Nature	
            •  Invisible	
  God	
  
What	
  is	
  Client	
  ?	
  Server?	
  

Client	
                                   Server	
  
•  From	
  your	
  computer	
              •  From	
  the	
  hos)ng	
  service	
  
•  All	
  the	
  user	
  interac)ons	
     •  Never	
  shown	
  directly,	
  
   happen	
  from	
  the	
  client	
          performs	
  and	
  executes	
  on	
  
                                              the	
  browser	
  
Stolen	
  from	
  my	
  professor	
  -­‐	
  
What	
  is	
  PHP?	
  

•  PHP	
  :	
  “Hypertext	
  Preprocessor.”	
  

•  “Widely	
  used	
  general-­‐purpose	
  scrip)ng	
  
   language	
  that	
  is	
  especially	
  suited	
  for	
  Web	
  
   development	
  and	
  can	
  be	
  embedded	
  into	
  
   HTML.”	
  	
  	
  -­‐	
  from	
  www.php.net-­‐	
  
How	
  does	
  PHP	
  act?	
  
           User	
  




             From	
  Codin’	
  for	
  the	
  web	
  Codin’	
  for	
  the	
  Web,	
  CHARLES	
  WYKE-­‐SMITH	
  
How	
  to	
  use?	
  
<!DOCTYPE	
  html	
  PUBLIC	
  "-­‐//W3C//DTD	
  XHTML	
  1.0	
  
     Transi)onal//EN"	
  
	
   "hkp://www.w3.org/TR/xhtml1/DTD/xhtml1-­‐
     transi)onal.dtd">	
  
<html	
  xmlns="hkp://www.w3.org/1999/xhtml"	
  xml:lang="en"	
  
                                                                    •  Can	
  be	
  embedded	
  into	
  
     lang="en">	
  
<head>	
                                                               HTML	
  page	
  
	
   <meta	
  hkp-­‐equiv="Content-­‐Type"	
  content="text/
     html;	
  charset=un-­‐8"/>	
  
	
   <)tle>Who	
  are	
  you?</)tle>	
  
</head>	
  
<body>	
  
                                                                    •  Starts	
  with	
  	
  	
  <?php	
  
                                                                    •  Closes	
  with	
  	
  	
  	
  ?>	
  
<?php	
  	
  

print	
  "Hello";	
  

?>	
  

</body>	
  
</html>	
  
What	
  is	
  Database?	
  

•  A	
  database	
  is	
  a	
  collec)on	
  of	
  tables	
  (made	
  up	
  
   of	
  columns	
  and	
  rows)	
  that	
  stores	
  informa)on.	
  	
  
What	
  is	
  MySQL?	
  

•  MySQL	
  :	
  most	
  popular	
  open-­‐source	
  database	
  
•  Database	
  Management	
  System	
  (DBMS)	
  

•  Cf	
  )	
  	
  Oracle	
  and	
  Microsor’s	
  SQL	
  Serve	
  are	
  also	
  
   database,	
  and	
  are	
  compe)tors	
  to	
  MySQL	
  
PHP	
  &	
  mySQL	
  
How	
  to	
  use?	
  



•  	
  PHP’s	
  mysql_query()	
     •  $result	
  =	
  mysql_query(SQL	
  
                                       command,	
  ➝	
  database	
  
                                       connec)on);	
  
Why	
  use	
  PHP	
  and	
  MySQL?	
  

•  Easy	
  to	
  edit	
  and	
  update	
  
•  Let	
  the	
  users	
  fill	
  in	
  the	
  space	
  (ex	
  :	
  facebook	
  my	
  pages,	
  blogs,	
  etc…)	
  
•  Save	
  and	
  Access	
  to	
  Database	
  (impossible	
  with	
  html)	
  
•  and	
  more…	
  


                    TO	
  MAKE	
  A	
  DYNAMIC	
  WEBSITE	
  
All	
  in	
  all,	
  
Examples	
  of	
  Dynamic	
  Websites	
  
wordpress	
  
Framework	
  and	
  template	
  for	
  making	
  pornolio	
  websites	
  and	
  blog	
  
-­‐>	
  	
  To	
  edit	
  and	
  update	
  easily	
  
wordpress	
  
Framework	
  and	
  template	
  for	
  making	
  pornolio	
  websites	
  and	
  blog	
  
-­‐>	
  	
  To	
  edit	
  and	
  update	
  easily	
  
shopify	
  
Framework	
  and	
  template	
  for	
  making	
  shopping	
  mall.	
  
-­‐>	
  	
  To	
  remember	
  user’s	
  interac)ons	
  
facebook	
  
Social	
  networking	
  service	
  
-­‐>	
  To	
  provide	
  a	
  planorm	
  for	
  the	
  users	
  to	
  fill	
  in	
  and	
  share	
  the	
  contents	
  
ny/mes	
  
All	
  about	
  organizing	
  data	
  
Data	
  visualiza/on	
  
Ny)mes	
  interac)ve	
  graphics	
  
-­‐>	
  To	
  provide	
  real	
  )me	
  interac)ve	
  data	
  visualiza)on	
  
Wefeelfine.org	
  
Web	
  project	
  to	
  sort	
  and	
  view	
  blog	
  posts	
  with	
  emo)onal	
  contents	
  
-­‐>	
  To	
  provide	
  a	
  different	
  interface	
  and	
  meaning	
  for	
  the	
  web	
  
Interac/ve	
  Web	
  Art	
  Projects	
  
Aaron	
  Koblin,	
  Ten	
  Thousand	
  Cents	
  
-­‐>	
  To	
  explore	
  new	
  possibili)es	
  for	
  engaging	
  users	
  as	
  part	
  of	
  the	
  art	
  project	
  
YOUR	
  WORK	
  GOES	
  HERE	
  
                                  ?	
  
Please	
  do	
  not	
  hesitate	
  to	
  explore	
  with	
  crea)ve	
  projects	
  
           engaging	
  dynamic	
  web	
  technologies	
  	
  	
  

Week01 jan19 introductionto_php

  • 1.
    Introduc)on  to  PHP   TCNJ  –  Web  Design  2  :  Dynamic   By  Jean  Ho  Chu   Week  01.  Jan  19.  2012  
  • 2.
    What  is  Dynamic  Website?   Dynamic  Website   Sta/c  Website   •  ASP.NET,  JSP,  Ruby  on  rail,  PHP,  etc     •  HTML,  Javascript,  etc   •  Scrip)ng  language   •  Compiled  language     •  Generates  the  code  for  the  site   •  Only  displays  pages   •  Acts  on  the  server,  lives  on  the  server   •  Acts,  lives  anywhere  clients  are   •  Server  Side  Programming   •  Client  Side  Programming   •  Back  End  Development   •  Front  End  Development   •  Has  memories   •  No  memories   •  Responsive,  malleable   •  Not  responsive   •  More  difficult  to  develop  the  ini)al   •  Quick  and  cheap  to  develop  the  ini)al   website   website  
  • 3.
    This  is  Sta)c  HTML  Website…  
  • 4.
    This  is  Dynamic  Website  !   Fast,  Clean,  Easy   Molds  &  Frames   Contents   Diverse  results!   +   =   Server  side  code  provides     Contents  are   The  html  page  of     templates   provided  by  users  or   what  the  users  see  is   from  the  server   from  databases    generated!  
  • 5.
    What  is  Client  ?  Server?   Client   Server   •  Visible  Nature   •  Invisible  God  
  • 6.
    What  is  Client  ?  Server?   Client   Server   •  From  your  computer   •  From  the  hos)ng  service   •  All  the  user  interac)ons   •  Never  shown  directly,   happen  from  the  client   performs  and  executes  on   the  browser  
  • 7.
    Stolen  from  my  professor  -­‐  
  • 8.
    What  is  PHP?   •  PHP  :  “Hypertext  Preprocessor.”   •  “Widely  used  general-­‐purpose  scrip)ng   language  that  is  especially  suited  for  Web   development  and  can  be  embedded  into   HTML.”      -­‐  from  www.php.net-­‐  
  • 9.
    How  does  PHP  act?   User   From  Codin’  for  the  web  Codin’  for  the  Web,  CHARLES  WYKE-­‐SMITH  
  • 10.
    How  to  use?   <!DOCTYPE  html  PUBLIC  "-­‐//W3C//DTD  XHTML  1.0   Transi)onal//EN"     "hkp://www.w3.org/TR/xhtml1/DTD/xhtml1-­‐ transi)onal.dtd">   <html  xmlns="hkp://www.w3.org/1999/xhtml"  xml:lang="en"   •  Can  be  embedded  into   lang="en">   <head>   HTML  page     <meta  hkp-­‐equiv="Content-­‐Type"  content="text/ html;  charset=un-­‐8"/>     <)tle>Who  are  you?</)tle>   </head>   <body>   •  Starts  with      <?php   •  Closes  with        ?>   <?php     print  "Hello";   ?>   </body>   </html>  
  • 11.
    What  is  Database?   •  A  database  is  a  collec)on  of  tables  (made  up   of  columns  and  rows)  that  stores  informa)on.    
  • 12.
    What  is  MySQL?   •  MySQL  :  most  popular  open-­‐source  database   •  Database  Management  System  (DBMS)   •  Cf  )    Oracle  and  Microsor’s  SQL  Serve  are  also   database,  and  are  compe)tors  to  MySQL  
  • 13.
  • 14.
    How  to  use?   •   PHP’s  mysql_query()   •  $result  =  mysql_query(SQL   command,  ➝  database   connec)on);  
  • 15.
    Why  use  PHP  and  MySQL?   •  Easy  to  edit  and  update   •  Let  the  users  fill  in  the  space  (ex  :  facebook  my  pages,  blogs,  etc…)   •  Save  and  Access  to  Database  (impossible  with  html)   •  and  more…   TO  MAKE  A  DYNAMIC  WEBSITE   All  in  all,  
  • 16.
  • 17.
    wordpress   Framework  and  template  for  making  pornolio  websites  and  blog   -­‐>    To  edit  and  update  easily  
  • 18.
    wordpress   Framework  and  template  for  making  pornolio  websites  and  blog   -­‐>    To  edit  and  update  easily  
  • 19.
    shopify   Framework  and  template  for  making  shopping  mall.   -­‐>    To  remember  user’s  interac)ons  
  • 20.
    facebook   Social  networking  service   -­‐>  To  provide  a  planorm  for  the  users  to  fill  in  and  share  the  contents  
  • 21.
    ny/mes   All  about  organizing  data  
  • 22.
    Data  visualiza/on   Ny)mes  interac)ve  graphics   -­‐>  To  provide  real  )me  interac)ve  data  visualiza)on  
  • 23.
    Wefeelfine.org   Web  project  to  sort  and  view  blog  posts  with  emo)onal  contents   -­‐>  To  provide  a  different  interface  and  meaning  for  the  web  
  • 24.
    Interac/ve  Web  Art  Projects   Aaron  Koblin,  Ten  Thousand  Cents   -­‐>  To  explore  new  possibili)es  for  engaging  users  as  part  of  the  art  project  
  • 25.
    YOUR  WORK  GOES  HERE   ?   Please  do  not  hesitate  to  explore  with  crea)ve  projects   engaging  dynamic  web  technologies  