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

Slides:



Advertisements
Similar presentations
Web Database Programming Connecting Database to Web.
Advertisements

Everyday Italian Giada De Laurentiis Harry Potter J K. Rowling Learning XML Erik T. Ray CSCI 305 Introduction to Database.
Hypertext Markup Language. Platform: - Independent  This means it can be interpreted on any computer regardless of the hardware or operating system.
XP Browser and Basics1. XP Browser and Basics2 Learn about Web browser software and Web pages The Web is a collection of files that reside.
Web development  World Wide Web (web) is the Internet system for hypertext linking.  A hypertext document (web page) is an online document. It contains.
Master’s course Bioinformatics Data Analysis and Tools Lecture 6: Internet Basics Centre for Integrative Bioinformatics.
Computer Science 1611 Internet & Web Creating Webpages Hypertext and the HTML Markup Language.
CIS101 Introduction to Computing
Intermediate PHP & MySQL
Topics in this presentation: The Web and how it works Difference between Web pages and web sites Web browsers and Web servers HTML purpose and structure.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
Implementing Application Protocols. Overview An application protocol facilitates communication between applications. For example, an client uses.
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.
David Evans CS200: Computer Science University of Virginia Computer Science Class 29: Vocational Skills How to Build a.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
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.
NETWORK CENTRIC COMPUTING (With included EMBEDDED SYSTEMS)
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
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.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
DAT602 Database Application Development Lecture 14 HTML.
Application Sketch home.htm delete.php updateform.php display.php insert.php insertform.htm update.php Data Base Hyperlink Information exchange with database.
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.
INTERNET APPLICATION DEVELOPMENT For More visit:
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.
Introduction to InfoSec – Recitation 7 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
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.
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.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
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.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
1 John Magee 9 November 2012 CS120 Lecture 17: The World Wide Web and HTML Web Publishing.
David Evans CS200: Computer Science University of Virginia Computer Science Class 17: Mutation M. C. Escher, Day and Night.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
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.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
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!
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
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.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Web Design Terminology Unit 2 STEM. 1. Accessibility – a web page or site that address the users limitations or disabilities 2. Active server page (ASP)
IST 210: PHP Basics IST 210: Organization of Data IST2101.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
Introduction to HTML.
Project 1 Introduction to HTML.
Introduction to Dynamic Web Programming
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.
HTTP and HTML HTML HTTP HTTP – Standardize the packaging
Presentation transcript:

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

10 April 2002CS 200 Spring Menu Building a Dynamic Web Site SQL PHP HTML Scheme Job listings at dice.com : 1417 ~$40K 60~$60K 4229 $80-250K 1

10 April 2002CS 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

10 April 2002CS 200 Spring HTML Language for controlling presentation of web pages Uses formatting tags enclosed between Not a powerful language – no way to make procedures or jump

10 April 2002CS 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 the inner element a paragraph. Element ::= Element Center the element horizontally on the page. Element ::= Element Display the element in bold. Element ::= Text

10 April 2002CS 200 Spring Dynamic Web Sites

10 April 2002CS 200 Spring Dynamic Web Site Client (Browser) GET /cs200/notes/presidents.php3 … Server

10 April 2002CS 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

10 April 2002CS 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

10 April 2002CS 200 Spring PHP Code A universal programming language –Everything you can do in Scheme you can do in PHP –Everything you can do in PHP, you can do in Scheme Imperative Language –Designed to support a style of programming where most of the work is done using assignment

10 April 2002CS 200 Spring Learning New Languages Syntax –Where the {, ;, $, etc. all go –If you can read a BNF grammar, this should be easy Semantics –What does it mean –Learning the evaluation rules –Harder, but most programming languages have very similar evaluation rules

10 April 2002CS 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.

10 April 2002CS 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.

10 April 2002CS 200 Spring Using a Database Web requests are 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

10 April 2002CS 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

10 April 2002CS 200 Spring SQL Structured Query Language (SQL) –(Almost) all databases use it Database is tables of fields containing values numberlastnamefirstnamecollege 1WashingtonGeorge 2AdamsJohnHarvard 3JeffersonThomas William and Mary

10 April 2002CS 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

10 April 2002CS 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

10 April 2002CS 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;

10 April 2002CS 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;

10 April 2002CS 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");

10 April 2002CS 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 ?>

10 April 2002CS 200 Spring The Resulting Page

10 April 2002CS 200 Spring This is Powerful Just change the query to get a new page Query can be a string generated by your program! –Based on user input and hyperlink clicks See the example site $result = mysql_query("SELECT lastname, firstname FROM presidents WHERE college='William and Mary' ORDER BY lastname");

10 April 2002CS 200 Spring Charge For Friday: come up with at least one idea for a dynamic web site You will describe your idea at the beginning of class Friday, then work in groups to settle on project ideas