David Evans CS200: Computer Science University of Virginia Computer Science Class 29: Vocational Skills How to Build a.

Slides:



Advertisements
Similar presentations
Chapter 16 The World Wide Web.
Advertisements

Hypertext Markup Language. Platform: - Independent  This means it can be interpreted on any computer regardless of the hardware or operating system.
CIS101 Introduction to Computing Week 05. Agenda Your questions Exam next week - Excel Introduction to the Internet & HTML Online HTML Resources Using.
Computer Science 1611 Internet & Web Creating Webpages Hypertext and the HTML Markup Language.
CIS101 Introduction to Computing Week 05. Agenda Your questions CIS101 Survey Introduction to the Internet & HTML Online HTML Resources Using the HTML.
CIS101 Introduction to Computing
Introduction to HTML 2006 CIS101. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
DT228/3 Web Development JSP: Directives and Scripting elements.
Introduction to HTML 2006 INT197B. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
CIS101 Introduction to Computing Week 06. Agenda Your questions Excel Exam during second hour Our status after the snow day Introduction to the Internet.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Class 24: Programming with Objects University of Virginia cs1120 David Evans.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 28: Implementing Interpreters.
Computer Sciences Department
Chapter 16 The World Wide Web. 2 Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Write basic HTML.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Creating a Basic Web Page
Unit 1 – Developing a Web Page. Objectives:  Learn the history of the Web and HTML  Describe HTML standards and specifications  Understand HTML elements.
DAT602 Database Application Development Lecture 14 HTML.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
Today’s Topic Language of web page - HTML (Hypertext Markup Language)
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
16-1 The World Wide Web The Web An infrastructure of distributed information combined with software that uses networks as a vehicle to exchange that information.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
NASRULLAH KHAN.  Lecturer : Nasrullah   Website :
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Introduction to HTML. What is a HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup tags  The.
David Evans CS150: Computer Science University of Virginia Computer Science Class 30: Vocational Skills How (and Why)
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
CA Professional Web Site Development Class 2: Anatomy of a Web Site and Web Page & Intro to HTML.
Web Programming Brian Toone 8/27/2014. Outline for today 1.Understanding the architecture of the web 2.Overview of programming languages – Client-side.
David Evans CS200: Computer Science University of Virginia Computer Science Class 17: Mutation M. C. Escher, Day and Night.
How the Web Works Building a Website – Lesson 1. How People Access the Web Browsers People access websites using software called a web browser. To view.
Producing a high-impact web experience by integrate Macromedia Flash and ASP By Katie Tuttle CS 330: Internet Architecture and Programming Project.
HTML Basics Computers. What is an HTML file? *HTML is a format that tells a computer how to display a web page. The documents themselves are plain text.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
David Evans CS200: Computer Science University of Virginia Computer Science Class 16: Mutation M. C. Escher, Day and Night.
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!
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
NASRULLAH KHAN.  Lecturer : Nasrullah   Website :
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
Creating Databases applications for the Web: week 2 Basic HTML review, forms HW: Identify unique source for asp, php, Open Source, MySql, Access.
Invitation to Computer Science 6 th Edition Chapter 10 The Tower of Babel.
LBSC 690 Session 4 Programming. Languages How do we learn a language? Learn by listening Then reading Then writing How do we teach programming? Learn.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: Vocational Skills (How to Build.
The Internet Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
Tonga Institute of Higher Education IT 141: Information Systems
WWW and HTTP King Fahd University of Petroleum & Minerals
ISC440: Web Programming 2 Server-side Scripting PHP 3
Class 29: Vocational Skills How to Build a Dynamic Web Site
Chapter 27 WWW and HTTP.
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Chapter 16 The World Wide Web.
Tutorial 10: Programming with javascript
Presentation transcript:

David Evans CS200: Computer Science University of Virginia Computer Science Class 29: Vocational Skills How to Build a Dynamic Web Site

31 March 2004CS 200 Spring Vocational Skills SQL PHP HTML Scheme Job listings at monster.com (31 March 2004) : “more than 5000” $30-50K 203 in last 24 hours 785 $40-$150K “more than 5000”$80-$400K 3570 posted in last 14 days 0 $200K?

31 March 2004CS 200 Spring Covers topics primarily selected for their practical (not intellectual) value Covers material found in “For Dummies” books (but we’ll cover it differently) There is no “Computability Theory for Dummies”, “Complexity Theory for Dummies”, “Higher Order Procedures for Dummies”, “Recursive Definitions for Dummies”, etc. book Today’s Aberrant Class

31 March 2004CS 200 Spring HyperText Transfer Protocol Client (Browser) GET /cs200/index.html HTTP/1.0 … Contents of file Server HTML – hypertext markup language Way of describing hypertext documents

31 March 2004CS 200 Spring HTML: HyperText Markup Language Language for controlling presentation of web pages Uses formatting tags –Enclosed between Not a powerful language (we will learn what this means more precisely next week) –no way to make procedures or jump

31 March 2004CS 200 Spring HTML Grammar Excerpt Document ::= Header Body Header ::= HeadElements HeadElements ::= HeadElement HeadElements HeadElements ::= HeadElement ::= Element Body ::= Elements Elements ::= Element Elements Elements ::= Element ::= Element Make Element a paragraph. Element ::= Element Center Element horizontally on the page. Element ::= Element Display Element in bold. Element ::= Text What is a HTML interpreter?

31 March 2004CS 200 Spring Dynamic Web Sites Programs that run on the client’s machine –Java, JavaScript, Flash, etc.: language must be supported by the client’s browser (so they are usually flaky and don’t work for most visitors) –Used (almost exclusively) to make annoying animations to make advertisements more noticeable Programs that run on the web server –Can be written in any language, just need a way to connect the web server to the program –Program generates regular HTML – works for everyone –(Almost) Every useful web site does this

31 March 2004CS 200 Spring Dynamic Web Site Client (Web Browser) “HTML Interpreter” GET /cs200/notes/presidents.php3 … Server

31 March 2004CS 200 Spring Dynamic Web Site Client File Server GET /cs200/notes/presidents.php3 Read ~evans/public_html/cs200/notes/presidents.php3 Presidents of the United States Presidents of the United States <? $hostName = "dbm1.itc.virginia.edu"; $userName = "dee2b"; $password = "quist"; $dbName = "dee2b_presidents"; … Request Processor

31 March 2004CS 200 Spring Processing a GET Request Presidents of the United States Presidents of the United States <? $hostName = "dbm1.itc.virginia.edu"; $userName = "dee2b"; $password = "quist"; $dbName = "dee2b_presidents"; … Regular HTML: Send through to client PHP Code: (inside ) Evaluate using PHP evaluator, send result to client PHP Evaluator to Client

31 March 2004CS 200 Spring PHP Code A universal programming language –Everything you can compute in Scheme you can compute in PHP –Everything you can compute in PHP, you can compute in Scheme –Friday we will explain why more convincingly Imperative Language –Designed to support a style of programming where most of the work is done using assignment

31 March 2004CS 200 Spring Learning New Languages Syntax: Where the {, ;, $, etc. all go –If you can understand a BNF grammar, this is easy Semantics: What does it mean –Learning the evaluation rules –Harder, but most programming languages have very similar evaluation rules Style –What are the idioms and customs of experienced programmers in that language? Takes many years to learn Need it to be a “professional” PHP programmer, but not to make a useful program

31 March 2004CS 200 Spring PHP If Instruction ::= if ( Expression ) { Instructions } Evaluate Expression. If it evaluates to true, evaluate the Instructions. It is similar to (if Expression (begin Instructions)) Difference is what “true” means. In Scheme, it means anything that is not #f. In PHP it means anything that is not 0, the empty string, or a few other things.

31 March 2004CS 200 Spring PHP Example $i = 1; $a = 1; $b = 1; while ($i <= 10) { print "Fibonacci $i = $b "; $next = $a + $b; $a = $b; $b = $next; $i = $i + 1; } ; Assignment: (define i 1) or (set! i 1) $i is a variable (all variables start with $ ) Instruction ::= while ( Expression ) { Instructions } As long as Expression evaluates to true, keep doing Instructions.

31 March 2004CS 200 Spring Using a Database HTTP is stateless –No history of information from previous requests To do something useful, we probably need some state that changes as people visit the site That’s what databases are for – store, manipulate, and retrieve data

31 March 2004CS 200 Spring Presidents of the United States Presidents of the United States <? $hostName = "dbm1.itc.virginia.edu"; $userName = "dee2b"; $password = "quist"; $dbName = "dee2b_presidents"; … Regular HTML: Send through to client PHP Code: (inside ) Evaluate using PHP evaluator, send result to client PHP Evaluator to Client Database SQL Command Values

31 March 2004CS 200 Spring SQL Structured Query Language (SQL) –(Almost) all databases use it Database is tables of fields containing values All fields have a type (and may have other attributes like UNIQUE)

31 March 2004CS 200 Spring Demo

31 March 2004CS 200 Spring SQL Commands Create a table CREATE TABLE presidents ( number INT PRIMARY KEY, lastname VARCHAR(100), firstname VARCHAR(100), college VARCHAR(100), startdate DATE, enddate DATE ) ; numberlastnamefirstnamecollegestartdateenddate presidents primary key – used to uniquely select and entry in the table all fields must have a type int – integer varchar(n) – string of up to n characters

31 March 2004CS 200 Spring SQL: Add Entry INSERT INTO presidents (number, lastname, firstname, college, startdate, enddate) VALUES (3, 'Jefferson', 'Thomas', 'William and Mary', ' ', ' '); numberlastnamefirstnamecollegestartdateenddate 3JeffersonThomas William and Mary presidents

31 March 2004CS 200 Spring SQL: Select SelectQuery ::= SELECT fields FROM table joinClause [WHERE conditions] [ORDER BY field [DESC]] SELECT * FROM presidents; SELECT lastname FROM presidents; SELECT lastname, firstname FROM presidents ORDER BY lastname; SELECT lastname, firstname FROM presidents WHERE college=‘William and Mary’ ORDER BY lastname;

31 March 2004CS 200 Spring Nesting Selects SELECT evaluates to a table, so of course, we can SELECT from that table SELECT lastname, firstname FROM (SELECT * FROM presidents WHERE college=‘William and Mary’) ORDER BY lastname;

31 March 2004CS 200 Spring SQL in PHP in HTML Presidents of the United States Presidents of the United States <? $hostName = "dbm1.itc.virginia.edu"; $userName = "dee2b"; $password = "quist"; $dbName = "dee2b_presidents"; mysql_connect($hostName, $userName, $password) or exit("Unable to connect to host $hostName"); mysql_select_db($dbName) or exit("Database $dbName does not exist on $hostName"); $result = mysql_query("SELECT lastname, firstname FROM presidents WHERE college='William and Mary' ORDER BY lastname");

31 March 2004CS 200 Spring $numrows = mysql_num_rows($result); $numcols = mysql_num_fields($result); print " "; print " "; for ($k = 0; $k < $numcols; $k = $k + 1) { print " ". mysql_field_name ($result, $k). " "; } print " "; for ($i = 0; $i < $numrows; $i++) { // $i++ is short for $i = $i + 1 for ($j = 0; $j < $numcols; $j++) { print " ". mysql_result ($result, $i, $j). " "; } print " "; } print " "; mysql_close(); // Close the database connection ?>

31 March 2004CS 200 Spring The Resulting Page

31 March 2004CS 200 Spring Charge Combining PHP, SQL and HTML is Very Powerful Query can be a string generated by your program! –Based on user input and hyperlink clicks Code can be generated based on what is in the database