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!

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Web Database Programming Connecting Database to Web.
IST 221 Internet Concepts and Applications Introduction to PHP.
1 CSE Students: Please do not log in yet. Check-in with Brian in the back. Review Days 3 and 4 in the book. Others: Please save your work and logout.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
Multiple Tiers in Action
Python and Web Programming
U:/msu/course/cse/103 Day 23, Slide 1 Review of Day 22 What query did you use to search for an actor by name? –Return matches.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
MIS2502: Data Analytics MySQL and SQL Workbench David Schuff
Figure 1. Hit analysis in 2002 of database-driven web applications Hits by Category in 2002 N = 73,873 Results Reporting 27% GME 26% Research 20% Bed Availability.
David Evans CS200: Computer Science University of Virginia Computer Science Class 29: Vocational Skills How to Build a.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
U:/msu/course/cse/103 Day 25, Slide 1 Back-up PHP Files If you have not yet passed the 3.0 BT, make back-up copies of ALL.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, October 18, 2012 Session 7: PHP.
Create an online booking system (login/registration)
Server-side Scripting Powering the webs favourite services.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
© 2003 By Default! A Free sample background from Slide 1 Week 2  Free PHP Hosting Setup  PHP Backend  Backend Security 
Nael Alian Introduction to PHP
U:/msu/course/cse/103 Day 10, Slide 1 CSE 103 Students: Your BTs have been graded. See Erica or Jo with questions or stay.
U:/msu/course/cse/103 Day 04, Slide 1 CSE students: Do not log in yet. Computers are SLOW today! Review days 13.
PHP meets MySQL.
Introduction to MySQL Lab no. 10 Advance Database Management System.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
U:/msu/course/cse/103 Day 06, Slide 1 CSE students: Do not log in yet. Review Day 6 in your textbook. Think about.
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
Creating PHPs to Insert, Update, and Delete Data CS 320.
Day 13, Slide 1 U:/msu/course/cse/103 CSE 103 Students: Review INNER and OUTER JOINs, Subqueries. Others: Please save your.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
XP Tutorial 8 Adding Interactivity with ActionScript.
© Anselm Spoerri Web Design Information Visualization Course Prof. Anselm Spoerri
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
U:/msu/course/cse/103 Day 03, Slide 1 CSE 103 Day 15: Database Design Students: –Read Day 2 in your textbook –Your BT feedback.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
U:/msu/course/cse/103 Day 08, Slide 1 CSE 103 Students: –Review days 7 and 8 if you need to go over relationships and INNER.
Creating Databases applications for the Web: week 2 Basic HTML review, forms HW: Identify unique source for asp, php, Open Source, MySql, Access.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: Vocational Skills (How to Build.
MYSQL AND MYSQL WORKBENCH MIS2502 Data Analytics.
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,
Day 22, Slide 1 CSE 103 Day 22 Non-students: Please logout by 10:12. Students:
Radoslav Georgiev Telerik Corporation
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
CSE 103 Day 20 Jo is out today; I’m Carl
Questions In the PHP script mysqltest.php :
Intro to PHP & Variables
Introduction to JavaScript
ISC440: Web Programming 2 Server-side Scripting PHP 3
A second look at JavaScript
Tutorial 6 PHP & MySQL Li Xu
Introduction to JavaScript
MySQL Web Application Connecting to a MySQL database
HTML Forms What are clients? What are servers?
Presentation transcript:

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! –Next chance: take one between FRIDAY and TUESDAY But don’t take one during the game(s); that would be lousy –In-class BT: next THURSDAY (or MONDAY, April 11)

U:/msu/course/cse/103 Day 21, Slide 2 Dynamically Generated Web Pages Dynamic web pages are generated as needed or as requested Allows you to make a huge number of pages from a single file using a “scripting language” such as PHP

U:/msu/course/cse/103 Day 21, Slide 3 Client requests The web server requests data from the database server based on the PHP script Database Server Web Server Serving PHP files that use a database

U:/msu/course/cse/103 Day 21, Slide 4 PHP and databases PHP connects to MySQL –Other database servers also supported Specify which database to connect to –Today we'll use the movies database Store queries in the PHP file –Web server sends them to database server –Database server sends results back Today we will start making a small “cast browser” set of pages

U:/msu/course/cse/103 Day 21, Slide 5 CSE 103 functions To simplify using PHP, we provide some common utilities for you –Can use require() just like include() in order to use a library –Functions in that file can be called from the requiring file –They save you time; not having to learn picky details about PHP –Feel free to examine the source code (Day 21 AFS) Start a new PHP page named actor.php in Dreamweaver. (Save in your web folder!) Include the function definitions from the file above by entering at the top of your new page (line 1) <?php require('/afs/msu/course/cse/103/php/cse103.php');?>

U:/msu/course/cse/103 Day 21, Slide 6 Test database connection Use set_database() to choose the database with –Server: "cse103.egr.msu.edu" –Database: "movies" –Username: "yourmsuNetID" –Password: "yourPID", with starting A capitalized Add the PHP function get_SQLversion() to the page in a print statement in the Add the PHP function get_SQLversion() to the page in a print statement in the –This function finds the version of the MySQL database server being used (4.1.8a-Debian_1-log) Test the page by browsing to it:

U:/msu/course/cse/103 Day 21, Slide 7 Variables in PHP Variables and constants let you store values for later use –The “value” of variables can change All PHP variables begin with a $ followed by a non-numeric character –Example: $name = 'Bob'; –Assigns the value Bob to the variable $name Only alphabetic, numeric, and _ characters are allowed in variable names

U:/msu/course/cse/103 Day 21, Slide 8 Query strings An SQL query is usually several lines long It is usually entered as a single string–in "quotes" It is usually assigned to a variable, so that it can easily be passed to functions The query itself should NOT end with ; but the PHP statement MUST end with one (OUTSIDE the quotes around the query) Example: $query = "SELECT MovieTitle, Year FROM tbl_Movies WHERE Year = 2004";

U:/msu/course/cse/103 Day 21, Slide 9 Using a query to generate a dynamic page Create an SQL query that finds FirstName and LastName of a person identified by ActorID –Use ActorID= to test the query Store this (and every query you ever use) in a variable Use print and the text_from_query() function to display the actor’s name –Check the Day 21 classwork page for documentation link

U:/msu/course/cse/103 Day 21, Slide 10 Using a query to generate a dynamic table Create a second SQL query that finds each movie, year, and role in which s/he has appeared – ordered by year –Continue to restrict by ID number Make a table on your page of the results of this query using print and table_from_query() –Check the support function documentation linked from the Day 21 page if you need to –Very similar to using text_from_query()

U:/msu/course/cse/103 Day 21, Slide 11 Movie information Create a new PHP page called movie.php Display name & year of movie (given MovieID) as a heading on the page (in tags) –Test with MovieID = Make a table displaying each credit number*, role in the movie, and name of actor playing it –Order by CreditNumber (*this field is in tbl_Roles) –Use the MySQL concat() function to put both first and last name of the actor into a single field

U:/msu/course/cse/103 Day 21, Slide 12 Passing information to a dynamic page Parameters can be passed in a URL Example: –…/actor.php?ActorID= Same syntax can be used by forms in a GET operation –We will look at this next time

U:/msu/course/cse/103 Day 21, Slide 13 Using parameters in PHP Each parameter becomes a special PHP variable, of the form $_GET['key']=value, where key is the name before = and value is after: –…/actor.php?ActorID=1234 makes $_GET['ActorID']=1234 –Key is case-sensitive: $_GET['actorid']=0 This value can be used later in PHP If you need to use it inside a quoted string, like a query, put curly braces { } around it: $query = "…WHERE ActorID={$_GET['ActorID']} …";

U:/msu/course/cse/103 Day 21, Slide 14 Exercise - Using parameters in PHP Modify the actor.php page to GET the value of ActorID from a parameter Change your queries to use the correct $_GET['xyz'] variable Test cases: –ActorID= is Sandra Bullock and ActorID= is Keanu Reeves

U:/msu/course/cse/103 Day 21, Slide 15 Exercise – Using parameters again Now modify the movie.php page to GET the value of MovieID from a parameter Change your queries to use the correct $_GET['xyz'] variable Test cases: –MovieID= is Star Wars III and MovieID= is Robots

U:/msu/course/cse/103 Day 21, Slide 16 Homework Check the link on today’s classwork page –Finish classwork –Read rest of Day 20 textbook, covering HTML forms –Work on UBTs!