Chapter 14 Web Database Programming Using PHP

Similar documents
Real SQL Programming 1

DBMS Project. COP Spring Final Submission Report

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

Facebook Twitter YouTube Google Plus Website

JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

A table is a collection of related data entries and it consists of columns and rows.

TIM 50 - Business Information Systems

database abstraction layer database abstraction layers in PHP Lukas Smith BackendMedia

INFORMATION BROCHURE Certificate Course in Web Design Using PHP/MySQL

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

Computational Mathematics with Python

Writing Scripts with PHP s PEAR DB Module

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Computational Mathematics with Python

VB.NET Programming Fundamentals

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: SQL and PL/SQL Fundamentals

A Brief Introduction to MySQL

All MySQL and PHP training students receive a copy of Apress' Beginning PHP and MySQL 5: From Novice to Professional and other related courseware.

Exercise 1: Python Language Basics

Introduction to Matlab

Oracle Database: SQL and PL/SQL Fundamentals NEW

Computational Mathematics with Python

WebSphere Business Monitor

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June Dr.-Ing.

Database Programming with PL/SQL: Learning Objectives

Utility Software II lab 1 Jacek Wiślicki, jacenty@kis.p.lodz.pl original material by Hubert Kołodziejski

PHP Tutorial From beginner to master

12 File and Database Concepts 13 File and Database Concepts A many-to-many relationship means that one record in a particular record type can be relat

Web Programming with PHP 5. The right tool for the right job.

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Oracle Database 10g Express

PYTHON Basics

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

Field Properties Quick Reference

Web Development using PHP (WD_PHP) Duration 1.5 months

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

PL / SQL Basics. Chapter 3

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Java Application Developer Certificate Program Competencies

Certified PHP Developer VS-1054

Information and Computer Science Department ICS 324 Database Systems Lab#11 SQL-Basic Query

How to Improve Database Connectivity With the Data Tools Platform. John Graham (Sybase Data Tooling) Brian Payton (IBM Information Management)

Oracle Database 12c: Introduction to SQL Ed 1.1

Microsoft Access 3: Understanding and Creating Queries

Package sjdbc. R topics documented: February 20, 2015

Short notes on webpage programming languages

Database Management System Choices. Introduction To Database Systems CSE 373 Spring 2013

Moving from C++ to VBA

MOC 20461C: Querying Microsoft SQL Server. Course Overview

Oracle Database 10g: Introduction to SQL

Programming Database lectures for mathema

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

USING MYWEBSQL FIGURE 1: FIRST AUTHENTICATION LAYER (ENTER YOUR REGULAR SIMMONS USERNAME AND PASSWORD)

Using Temporary Tables to Improve Performance for SQL Data Services

Chapter 13. Introduction to SQL Programming Techniques. Database Programming: Techniques and Issues. SQL Programming. Database applications

Oracle Database: SQL and PL/SQL Fundamentals NEW

MYSQL DATABASE ACCESS WITH PHP

CS346: Database Programming.

Vendor: Brio Software Product: Brio Performance Suite

Arrays in Java. Working with Arrays

Relational Database: Additional Operations on Relations; SQL

Introduction to the Oracle DBMS

Real SQL Programming. Persistent Stored Modules (PSM) PL/SQL Embedded SQL

Webapps Vulnerability Report

ISI ACADEMY Web applications Programming Diploma using PHP& MySQL

Database Query 1: SQL Basics

DIPLOMA IN WEBDEVELOPMENT

IENG2004 Industrial Database and Systems Design. Microsoft Access I. What is Microsoft Access? Architecture of Microsoft Access

Unit 3. Retrieving Data from Multiple Tables

Stored Documents and the FileCabinet

Tutorial 6 Creating a Web Form. HTML and CSS 6 TH EDITION

Web Forms for Marketers 2.3 for Sitecore CMS 6.5 and

Relational Databases. Christopher Simpkins

SQL Injection Attack Lab Using Collabtive

Database migration using Wizard, Studio and Commander. Based on migration from Oracle to PostgreSQL (Greenplum)

Connecting to a Database Using PHP. Prof. Jim Whitehead CMPS 183, Spring 2006 May 15, 2006

Introduction to Microsoft Jet SQL

Trial version of GADD Dashboards Builder

Data Transfer Tips and Techniques

Arrays. number: Motivation. Prof. Stewart Weiss. Software Design Lecture Notes Arrays

Section of DBMS Selection & Evaluation Questionnaire

Information Systems SQL. Nikolaj Popov

Programming in Python V: Accessing a Database

Writing MySQL Scripts With Python's DB-API Interface

Talking to Databases: SQL for Designers

Access Queries (Office 2003)

Python and MongoDB. Why?

Collections and iterators

SQL Programming. CS145 Lecture Notes #10. Motivation. Oracle PL/SQL. Basics. Example schema:

Oracle Database 11g SQL

IBM DB2 for Linux, UNIX, and Windows. Deploying IBM DB2 Express-C with PHP on Ubuntu Linux

ICAB4136B Use structured query language to create database structures and manipulate data

How-To: MySQL as a linked server in MS SQL Server

Creating Database Tables in Microsoft SQL Server

Advanced Online Media Dr. Cindy Royal Texas State University - San Marcos School of Journalism and Mass Communication

Contents. 9-1 Copyright (c) N. Afshartous

Answers to Review Questions Chapter 7

Thank you for using AD Bulk Export 4!

Variables, Constants, and Data Types

Transcription:

Chapter 14 Web Database Programming Using PHP Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 14 Outline A Simple PHP Example Overview of Basic Features of PHP Overview of PHP Database Programming

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

A Simple PHP Example PHP Open source general-purpose scripting language Comes installed with the UNIX operating system

A Simple PHP Example (cont d.) DBMS Bottom-tier database server PHP Middle-tier Web server HTML Client tier

A Simple PHP Example (cont d.) Example Figure 14.1(a) PHP script stored in: http://www.myserver.com/example/greeting.php <?php PHP start tag?> PHP end tag Comments: // or /* */

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_;

A Simple PHP Example (cont d.) PHP variable names Start with $ sign

Overview of Basic Features of PHP Illustrate features of PHP suited for creating dynamic Web pages that contain database access commands

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

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

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

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)

PHP Arrays 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

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

PHP Arrays (cont d.)

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

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 14.4 Figure 14.5

PHP Functions (cont d.)

PHP Server Variables and Built-in entries Forms $_SERVER auto-global built-in array variable Provides useful information about server where the PHP interpreter is running

PHP Server Variables and Forms (cont d.) Examples: $_SERVER['SERVER_NAME'] $_POST $_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

Overview of PHP Database PEAR DB library Programming Part of PHP Extension and Application Repository (PEAR) Provides functions for database access

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>

Connecting to a Database Query function (cont d.) $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

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

Retrieval Queries from Database $q Query result Tables $q->fetchrow() retrieve next record in query result and control loop $d=>getall Holds all the records in a query result in a single variable called $allresult

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