Web Database Programming Week 6 Using Templates & Updating Web Database.

Slides:



Advertisements
Similar presentations
Keys, Referential Integrity and PHP One to Many on the Web.
Advertisements

PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
Web Database Programming Connecting Database to Web.
NMED 3850 A Advanced Online Design February 25, 2010 V. Mahadevan.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
15 Chapter 15 Web Database Development Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
PHP and MySQL. Why Use a Database  Easy access to data  Simultaneous access by multiple users is handled properly  Security - easy to control access.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
14 1 Chapter 14 Database Connectivity and Web Development Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 14: Advanced Topics: DBMS, SQL, and ASP.NET
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Databases & Data Warehouses Chapter 3 Database Processing.
Chapter 1 1 © Prentice Hall, 2002 Database Design Dr. Bijoy Bordoloi Introduction to Database Processing.
Objects in PHP – Page 1 of 46CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: More Topics in PHP Reading: Williams.
1 ADVANCED MICROSOFT WORD Lesson 15 – Creating Forms and Working with Web Documents Microsoft Office 2003: Advanced.
Chapter 1 1 © Prentice Hall, 2002 Database Design Dr. Bijoy Bordoloi Introduction to Database Processing.
Deleting and Updating Records in MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
CSE3310: Web training A JumpStart for Project.
ASP.NET Programming with C# and SQL Server First Edition
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
Software Engineering 2003 Jyrki Nummenmaa 1 CASE Tools CASE = Computer-Aided Software Engineering A set of tools to (optimally) assist in each.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
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.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
MIS 327 Database Management system 1 MIS 327: DBMS Dr. Monther Tarawneh Dr. Monther Tarawneh Week 2: Basic Concepts.
FlexElink Winter presentation 26 February 2002 Flexible linking (and formatting) management software Hector Sanchez Universitat Jaume I Ing. Informatica.
USING XML AS A DATA SOURCE. Data binding is a process by which information in a data source is stored as an object in computer memory. In this presentation,
Creating PHPs to Insert, Update, and Delete Data CS 320.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
DT228/3 Web Development Databases. Querying a database: Partial info Search engines, on-line catalogues often need to allow user to search a database.
XML and Database.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Implementing The Middle Tier These slides.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
Computer Science & Engineering 2111 Database Objects 1 CSE 2111 Introduction to Database Management Systems.
Programming for the Web MySQL Command Line Using PHP with MySQL Dónal Mulligan BSc MA
SQL Injection By Wenonah Abadilla. Topics What is SQL What is SQL Injection Damn Vulnerable Web App SQLI Demo Prepared Statements.
Web Database Programming Using PHP
SQL Injection By Wenonah Abadilla.
Introduction to Dynamic Web Programming
Web Database Programming Using PHP
This shows the user interface and the SQL Select for a situation with two criteria in an AND relationship.
Microsoft Access 2003 Illustrated Complete
Design and Maintenance of Web Applications in J2EE
ISC440: Web Programming 2 Server-side Scripting PHP 3
Lecture 1: Multi-tier Architecture Overview
Chapter 1: The Database Environment
Structured Query Language
Please thank our sponsors!
Developing a Model-View-Controller Component for Joomla Part 3
Database Design and Development
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Database Connectivity and Web Development
Tutorial 6 PHP & MySQL Li Xu
Updating Databases With Open SQL
The Database Environment
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
Updating Databases With Open SQL
Presentation transcript:

Web Database Programming Week 6 Using Templates & Updating Web Database

PHP & HTML PHP code can be inserted anywhere in HTML code PHP code can output any HTML code Tightly mixed code (e.g. our sample code) –Hard to read –Hard to maintain –What if you want to change the appearance of the page? –What if you decide to use a different algorithm?

Separate Presentation and Processing An important user interface design principle –Easy to change interface or backend processing independently –Easier maintenance –Reusable code How? –Using templates

Template Define HTML presentation Placeholders –To be filled with data from PHP code Extensions to PHP –Smarty –PEAR Integrated Template

PEAR PHP Extension and Application Repository –Includes many packages DB, HTML_Template_IT, Authentication, Encryption, Graphics, XML, SOAP… –Core packages comes with PHP later –Optional packages needs to be installed

HTML_Template_IT Template html.html-template-it.phphttp://pear.php.net/manual/en/package. html.html-template-it.php Template Format: –Regular HTML –Placeholder {placeholder_name} –Block

HTML_Template_IT Class Use the class require_once “HTML/Template/IT.php” Create the object $template = new HTML_Template_IT(“template_dir”); Call the methods $template->loadTemplatefile(“template_filename”, true, true); $template->setCurrentBlock(“block_name”); $template->setVariable(“placeholder_name”, data); $template->parseCurrentBlock(); $template->show();

Update Database Table Operations –Create table structure –Change table structure –Delete table Record Operations –Insert a record to a table –Update a record –Delete a record

Making an Insert Form Example Notes –Recall that PHP will convert form field names into variables in the action page –use input type=hidden to set predefined and previously fixed values (like foreign keys); and to carry values forward

Using SQL for Insert SQL INSERT INTO tablename (columnnames) VALUES (values) Note –value do not have to come from form – they could, for example, be computed, or taken from another query –Remember ‘single quote’ for text values and not for numbers

An Update Form Example Notes –note the addition of a record ID value (which we must get from somewhere!); tells us which record we are updating.

Using SQL for Update SQL UPDATE tablename SET columnname = value,... WHERE condition Notes –value are set on all records matching the condition!

Deleting data from a table The form for the SQL part of the code is: DELETE FROM tablename WHERE condition Note: –all records matching the condition are deleted –if there is no where clause deletes all records in table