Chapter 11 Outline. A Simple PHP Example Overview of Basic Features of PHP Overview of PHP Database Programming. Slide 11-2

Similar documents
Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Options. Real SQL Programming 1. Stored Procedures. Embedded SQL

What is PHP? [1] Figure 1 [1]

PHP by Pearson Education, Inc. All Rights Reserved.

This lecture. PHP tags

Databases PHP I. (GF Royle, N Spadaccini ) PHP I 1 / 24

CS 377 Database Systems. Li Xiong Department of Mathematics and Computer Science Emory University

Introduction. Web Pages. Example Graph

Chapter 9 SQL in a server environment

Course Syllabus. Course Title. Who should attend? Course Description. PHP ( Level 1 (

Integrating Word, Excel, Access, and PowerPoint

CERTIFICATE IN WEB PROGRAMMING

Group A: Assignment No 2

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

CSCB20 Week 8. Introduction to Database and Web Application Programming. Anna Bretscher* Winter 2017

CS Final Exam Review Suggestions - Spring 2018

CSC Web Programming. Introduction to JavaScript

Server side basics CS380

relational Key-value Graph Object Document

CGS 3066: Spring 2017 SQL Reference

UNIT I Java Bean, HTML & Javascript

AIM. 10 September

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 14 Database Connectivity and Web Technologies

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015

Ch04 JavaServer Pages (JSP)

"Charting the Course... Intermediate PHP & MySQL Course Summary

The PHP language. Teaching you everything about PHP? Not exactly Goal: teach you how to interact with a database via web

MySQL for Developers. Duration: 5 Days

Web Architecture AN OVERVIEW

MySQL for Developers. Duration: 5 Days

Real SQL Programming 1

MongoDB Web Architecture

This course is intended for Java programmers who wish to write programs using many of the advanced Java features.

1. Data Model, Categories, Schemas and Instances. Outline

JavaScript CS 4640 Programming Languages for Web Applications

CGS 3066: Spring 2015 JavaScript Reference

JavaScript CS 4640 Programming Languages for Web Applications

CONTENTS IN DETAIL INTRODUCTION 1 THE FAQS OF LIFE THE SCRIPTS EVERY PHP PROGRAMMER WANTS (OR NEEDS) TO KNOW 1 2 CONFIGURING PHP 19

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel

Creating an Online Catalogue Search for CD Collection with AJAX, XML, and PHP Using a Relational Database Server on WAMP/LAMP Server

ICOM 5016 Database Systems. Database Users. User Interfaces and Tools. Chapter 8: Application Design and Development.

URLs and web servers. Server side basics. URLs and web servers (cont.) URLs and web servers (cont.) Usually when you type a URL in your browser:

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

SQL: Data Sub Language

DAVID M. KROENKE and DAVID J. AUER. DATABASE CONCEPTS, 7 th Edition. Chapter Seven. Database Processing Applications. Chapter Objectives

DRACULA. CSM Turner Connor Taylor, Trevor Worth June 18th, 2015

Planning and Designing Your Site p. 109 Design Concepts p. 116 Summary p. 118 Defining Your Site p. 119 The Files Panel p. 119 Accessing Your Remote

Alpha College of Engineering and Technology. Question Bank

Running SQL in Java and PHP

1Z Java SE 5 and 6, Certified Associate Exam Summary Syllabus Questions

B. V. Patel Institute of BMC & IT 2014

Extensions. Server-Side Web Languages. Uta Priss School of Computing Napier University, Edinburgh, UK. Libraries Databases Graphics

PHP 1. Introduction Temasek Polytechnic

Systems Programming & Scripting

PHP. Interactive Web Systems

PHP: Hypertext Preprocessor. A tutorial Introduction

1) What is the first step of the system development life cycle (SDLC)? A) Design B) Analysis C) Problem and Opportunity Identification D) Development

Database Processing. Fundamentals, Design, and Implementation. Global Edition

Today's Goals. CSCI 2910 Client/Server-Side Programming. Objects in PHP. Defining a Class. Creating a New PHP Object Instance

Chapter 9 SQL in a server environment

CENG 256 Internet Programming Draft

Database-Connection Libraries

CSE 344 APRIL 16 TH SEMI-STRUCTURED DATA

PHP & PHP++ Curriculum

3344 Database Lab. 1. Overview. 2. Lab Requirements. In this lab, you will:

Active Server Pages Architecture

A Web-Based Introduction

(Refer Slide Time: 00:23)

10/18/2017. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

Course Topics. The Three-Tier Architecture. Example 1: Airline reservations. IT360: Applied Database Systems. Introduction to PHP

Chapter 10 Web-based Information Systems

HTML 5 and CSS 3, Illustrated Complete. Unit L: Programming Web Pages with JavaScript

XQ: An XML Query Language Language Reference Manual

Web Development. with Bootstrap, PHP & WordPress

JavaScript Functions, Objects and Array

PHP and MySQL for Dynamic Web Sites. Intro Ed Crowley

Inf 202 Introduction to Data and Databases (Spring 2010)

Presentation and content are not always well separated. Most developers are not good at establishing levels of abstraction in JSPs

Assignment #3 CSCI 201 Spring % of course grade Title Weathermeister Back-End API Integration

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Module - P7 Lecture - 15 Practical: Interacting with a DBMS

Advanced PHP and MySQL

Web Programming Paper Solution (Chapter wise)

Pace University. Fundamental Concepts of CS121 1

WICKED COOL PHP. by William Steinmetz with Brian Ward. Real-World ScriptA Tl1at Solve DifficMlt ProblelMA. PRESS San Francisco NO STARCH

CSC Web Technologies, Spring Web Data Exchange Formats

Database System Concepts and Architecture

Client/Server-Architecture

Running SQL in Java and PHP

TUTORIAL QUESTION BANK

First Simple Interactive JSP example

5/1/17. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

Web Architecture and Technologies

Database Systems CSE 414

Bonus Content. Glossary

5/2/16. Announcements. NoSQL Motivation. The New Hipster: NoSQL. Serverless. What is the Problem? Database Systems CSE 414

Database and MySQL Temasek Polytechnic

Database Applications

Web Engineering (Lecture 08) WAMP

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Transcription:

Chapter 11 Outline A Simple PHP Example Overview of Basic Features of PHP Overview of PHP Database Programming Slide 11-2 1

Web Database Programming Using PHP Techniques for programming dynamic features into Web PHP Open source scripting language Interpreters provided free of charge Available on most computer platforms Slide 11-3 A Simple PHP Example PHP Open source general-purpose scripting language Comes installed with the UNIX operating system Slide 11-4 2

A Simple PHP Example (cont d.) DBMS Bottom-tier database server PHP Middle-tier Web server HTML Client tier Slide 11-5 Figure 11.1a PHP program segment for entering a greeting. continued on next slide Slide 11-6 3

Figure 11.1b-d (b) Initial form displayed by PHP program segment. (c) User enters name John Smith. (d) Form prints welcome message for John Smith. Slide 11-7 A Simple PHP Example (cont d.) Example Figure 11.1(a) PHP script stored in: http://www.myserver.com/example/greeting.php <?php PHP start tag?> PHP end tag Comments: // or /* */ Slide 11-8 4

A Simple PHP Example (cont d.) $_POST Auto-global predefined PHP variable Array that holds all the values entered through form parameters Arrays are dynamic Long text strings Between opening <<<_HTML_ and closing _HTML_; <html> </html> Slide 11-9 A Simple PHP Example (cont d.) PHP variable names Start with $ sign Slide 11-10 5

Overview of Basic Features of PHP Illustrate features of PHP suited for creating dynamic Web pages that contain database access commands Slide 11-11 PHP Variables, Data Types, and Programming Constructs PHP variable names Start with $ symbol Can include characters, letters, and underscore character (_) Main ways to express strings and text Single-quoted strings Double-quoted strings Here documents Single and double quotes Slide 11-12 6

PHP Variables, Data Types, and Programming Constructs (cont d.) Period (.) symbol String concatenate operator Single-quoted strings Literal strings that contain no PHP program variables Double-quoted strings and here documents Values from variables need to be interpolated into string $query="select * from music where Albumname='$_POST[searchname]' "; Slide 11-13 PHP Variables, Data Types, and Programming Constructs (cont d.) Numeric data types Integers and floating points Programming language constructs For-loops, while-loops, and conditional ifstatements Boolean expressions Slide 11-14 7

Figure 11.2 Illustrating basic PHP string and text values. Slide 11-15 PHP Variables, Data Types, and Programming Constructs (cont d.) Comparison operators == (equal),!= (not equal), > (greater than), >= (greater than or equal), < (less than), and <= (less than or equal) Slide 11-16 8

PHP Arrays Can hold database query results Two-dimensional arrays First dimension representing rows of a table Second dimension representing columns (attributes) within a row Main types of arrays: Numeric and associative Slide 11-17 PHP Arrays (cont d.) Numeric array Associates a numeric index with each element in the array Indexes are integer numbers Start at zero Grow incrementally Associative array Provides pairs of (key => value) elements Slide 11-18 9

Figure 11.3 Illustrating basic PHP array processing. Slide 11-19 PHP Arrays (cont d.) Techniques for looping through arrays in PHP Count function Returns current number of elements in array Sort function Sorts array based on element values in it Slide 11-20 10

PHP Functions Functions Define to structure a complex program and to share common sections of code Arguments passed by value Examples to illustrate basic PHP functions Figure 11.4 Figure 11.5 Slide 11-21 Figure 11.4 Rewriting program segment P1 as P1 using functions. Slide 11-22 11

Figure 11.5 Illustrating a function with arguments and return value. Slide 11-23 PHP Server Variables and Forms Built-in entries $_SERVER auto-global built-in array variable Provides useful information about server where the PHP interpreter is running Slide 11-24 12

PHP Server Variables and Forms (cont d.) Examples: $_POST $_SERVER['SERVER_NAME'] $_SERVER['REMOTE_ADDRESS'] $_SERVER['REMOTE_HOST'] $_SERVER['PATH_INFO'] $_SERVER['QUERY_STRING'] $_SERVER['DOCUMENT_ROOT'] Provides input values submitted by the user through HTML forms specified in <INPUT> tag Slide 11-25 Overview of PHP Database Programming PEAR DB library Part of PHP Extension and Application Repository (PEAR) Provides functions for database access Slide 11-26 13

Connecting to a Database Library module DB.php must be loaded DB library functions accessed using DB::<function_name> DB::connect('string') Function for connecting to a database Format for 'string' is: <DBMS software>://<user account>:<password>@<database server> Slide 11-27 Figure 11.6 Connecting to a database, creating a table, and inserting a record. Slide 11-28 14

Some Database Functions Query function $d->query takes an SQL command as its string argument Sends query to database server for execution $d >seterrorhandling(pear_error_die) Terminate program and print default error messages if any subsequent errors occur Slide 11-29 Collecting Data from Forms and Inserting Records Collect information through HTML or other types of Web forms Create unique record identifier for each new record inserted into the database PHP has a function $d >nextid to create a sequence of unique values for a particular table Placeholders Specified by? symbol Slide 11-30 15

Retrieval Queries from Database Tables $q Variable that holds query result $q->fetchrow() retrieve next record in query result and control loop $allresult = $d->getall(query) Holds all the records in a query result in a single variable called $allresult Slide 11-31 Figure 11.7 Illustrating database retrieval queries. Slide 11-32 16

Other techniques PHP runs on server Sends HTML to client Many other languages/technologies for Web Db programming Examples: Java servlets: Java objects on server, interact with client Store information about interaction session Slide 11-33 Other techniques (cont.) Java Server Pages (JSP) Creates dynamic Web pages through scripting at server to send to client (somewhat like PHP) JavaScript Scripting language, can run at client or server Java Script Object Notation (JSON): Text-based representation of objects Similar function to XML Used in many NOSQL systems Slide 11-34 17

Summary PHP scripting language Very popular for Web database programming PHP basics for Web programming Data types Database commands include: Creating tables, inserting new records, and retrieving database records Looping over a query result Slide 11-35 18