Web Database Programming Using PHP

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Introducing JavaScript
A Guide to Unix Using Linux Fourth Edition
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
The Web Warrior Guide to Web Design Technologies
Microsoft Access Course 1. Introduction to the user interface.
Chapter 31 Basic Form-Processing Techniques JavaServer Pages By Xue Bai.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Guide To UNIX Using Linux Third Edition
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 &14 Intro to SQL Programming Techniques & Web DB + PhP.
Introduction to PHP. PHP PHP is the Hypertext Pre-processor –Script language –Embedded into HTML –Runs as Apache module –Can use DB (MySQL, Oracle, Microsoft.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PHP == ‘ Hypertext Preprocessor ’ Open-source, server-side scripting language Used to generate dynamic web-pages PHP scripts reside between reserved PHP.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
ASP.NET Programming with C# and SQL Server First Edition
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
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.
Web Design and Development for E-Business By Jensen J. Zhao Copyright 2003 Prentice Hall, Inc. Web Design and Development for E-Business Jensen J. Zhao.
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Website Development with PHP and MySQL Saving Data.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
Creating PHPs to Insert, Update, and Delete Data CS 320.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
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,
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
PHP using MySQL Database for Web Development (part II)
Introduction to Dynamic Web Programming
Chapter 6 JavaScript: Introduction to Scripting
CHAPTER 5 SERVER SIDE SCRIPTING
Web Database Programming Using PHP
PHP Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used repeatedly in.
PHP (PHP: Hypertext Preprocessor)
Introduction to Scripting
PDO Database Connections
JavaScript: Functions.
PHP Introduction.
JavaScript.
Intro to PHP & Variables
ISC440: Web Programming 2 Server-side Scripting PHP 3
PDO Database Connections
WEB PROGRAMMING JavaScript.
PDO Database Connections
PHP.
Chapter 15 Introduction to Rails.
Web DB Programming: PHP
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
IntroductionToPHP Static vs. Dynamic websites
Intro to PHP.
Tutorial 6 PHP & MySQL Li Xu
Tutorial 10: Programming with javascript
PHP PART 2.
PHP an introduction.
23 PHP.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

Web Database Programming Using PHP Chapter 14 Web Database Programming Using PHP

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 if- statements 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 Main types of arrays: 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 Associative 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 Examples to illustrate basic PHP 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 Forms Built-in entries $_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'] $_SERVER['REMOTE_ADDRESS'] $_SERVER['REMOTE_HOST'] $_SERVER['PATH_INFO'] $_SERVER['QUERY_STRING'] $_SERVER['DOCUMENT_ROOT'] $_POST Provides input values submitted by the user through HTML forms specified in <INPUT> tag

Overview of PHP Database Programming PEAR DB library 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 (cont’d.) 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

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 Tables Query result $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 PHP basics for Web programming 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