XML & RDBMS By Molly Gumpert for: LIS 469: XML Fall 2014 Professor Gerry Benoit.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
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.
NMED 3850 A Advanced Online Design February 1, 2010 V. Mahadevan.
XML Extensible Markup Language Standard supported by W3C (World Wide Web Consortium) HTML – End user oriented (presentation) XML – Application oriented.
Apache Tomcat Server – installation & use Server-side language-- use Java Server Pages Contrast Client-side languages HTML Forms Servers & Server-side.
Multiple Tiers in Action
Python and Web Programming
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Introducing XHTML: Module B: HTML to XHTML. Goals Understand how XHTML evolved as a language for Web delivery Understand the importance of DTDs Understand.
Creating Web Page Forms
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
JSP Standard Tag Library
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Languages in WEB Presented by: Jenisha Kshatriya BCM SS09.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Server-side Scripting Powering the webs favourite services.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
HTML 101 MPM What is a website? A website is basically a collection of web pages stored on a particular computer (called a web server) and accessed.
Tutorial 10 Adding Spry Elements and Database Functionality Dreamweaver CS3 Tutorial 101.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
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.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
WEB DESIGN UNIT 2 Unit 2 Module 2-5. WHAT HAVE YOU LEARNED?  What is the title tag do? Where does it show?  What are the tags that need to be on every.
CSS CSS is short for C ascading S tyle S heets. It is a new web page layout method that has been added to HTML to give web developers more control over.
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
Session 1 SESSION 1 Working with Dreamweaver 8.0.
GUI To Create a DB Table CS346 Fall Methods to create a table At your local server and/or remote server – Use MySQL Console and create it interactively.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
Data Binding with Tabular Data Control. Objective To understand Dynamic HTML data binding. To be able to sort and filter data directly on the client without.
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
>> PHP: Insert Query & Form Processing. Insert Query Step 1: Define Form Variables Step 2: Make DB Connection Step 3: Error Handling Step 4: Define the.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 8: Working with Style Sheets.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
PHP and SQL Server: Connection IST2101. Typical web application interaction (php, jsp…) database drivers 2IST210.
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
MySQL MySQL and PHP – interacting with a database.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
Database to HTML and Back again A programmers tale.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Connecting to External Data. Financial data can be obtained from a number of different data sources.
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
Apache Cocoon – XML Publishing Framework 데이터베이스 연구실 박사 1 학기 이 세영.
Generating XML Data from a Database Eugenia Fernandez IUPUI.
A Simple Website using Cascading Style Sheets (CSS) IST2101.
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Design and Development
BASIC PHP and MYSQL Edward S. Flores.
In Class Programming BIS1523 – Lecture 11.
Teaching slides Chapter 6.
Tutorial 6 PHP & MySQL Li Xu
Presentation transcript:

XML & RDBMS By Molly Gumpert for: LIS 469: XML Fall 2014 Professor Gerry Benoit

Uses  Relational databases allow for easy data storage, manipulation, and visualization and, when make correctly, help avoid errors.  xml files are a good way to make your DB data more interoperable with other systems  Though it can take a be time consuming to produce, once you have a working php script you can turn create xml files of your database data almost instantly.  These xml files are easily updatable when data is added, removed or updated in the database  In turn, websites created with these xml files are immediately updated with changes to the database without having to edit your other scripts

Client/Server Architecture Database User Server User interacts through an html form Form runs php script that connects to and queries database Result set outputted as a new xml file Xml file meets with existing xsl, css, and image files Formatted and styled xml file sent back to user’s browser Xml file

Example I began with a relational mySQL database designed and built during LIS458. The database serves a fictional art gallery and includes tables for artist information, art pieces, sales, deliveries and more.

html and php The “View Works” buttons under each artist on the Artist webpage link to three different php files.Artist webpage The php files are identical in every way except the WHERE statement in the sql query. Each artist is identified by a different “art_id” field $q = "SELECT w.work_id, w.title, w.series, w.medium, w.available, w.price, w.height, w.width, w.image_link FROM works AS w INNER JOIN collections AS c on w.work_id=c.work_id INNER JOIN artists on artists.art_id=c.art_id WHERE artists.art_id='1'";

php script <?php require ('mysqli_connect.php'); $q = "SELECT w.work_id, w.title, w.series, w.medium, w.available, w.price, w.height, w.width, w.image_link FROM works AS w INNER JOIN collections AS c on w.work_id=c.work_id INNER JOIN artists on artists.art_id=c.art_id WHERE artists.art_id='1'"; $r ($dbc, $q); if ($r) { $body = " "; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $body.=” ". $row['work_id']. " ". $row['title']. " ". $row['series']. " ". $row['medium']. " ". $row['available']. " ". $row['price']. " ". $row['height']. " ". $row['width']. " ". $row['image_link']. " "; } } else {print ' Error retrieving results '; $body.=" "; $resultfile = fopen('resultfile.xml', 'w+'); fwrite ($resultfile, $body); header( 'Location:resultfile.xml' ); mysqli_close($dbc);?> Opens and creates new xml file with the contents specified by $body variable Redirects browser to open new xml file Closes database connection Check for errors (truncated here for space) Creating the $body variable by writing tags, calling the sql results that will populate those tags Connect to DB (external script is reusable) Sql query joins three tables to find data on all the artworks by a specified artist Variable $r consists of database connection and sql query If both are correct, the if statement will run Writing the xml declaration and root tag and connecting the existing xsl file While statement runs through all the databse records called by the sql query and creates an associative array

resultfile.xml Without a connected stylesheet the php will output and redirect to a plain xml file. The same xml file “resultfile.xml” is rewritten everytime the script is run. This means any changes to the database will be reflected in the xml without any other changes elsewhere $resultfile = fopen('resultfile.xml', ’w'); fwrite ($resultfile, $body); header( 'Location:resultfile.xml' );

catalog.xsl* Series cm h x cm w $ No longer available for purchase The xsl file follows the Xpath structure to find certain tags and displays the data inside as directed. Tags allow for conditionals. Here works that are still available for purchase get special treatment. Creating an “img” element with a “src” attribute creates an html string to link to images: *Some elements have been removed for space. View the entire page here.here

Adding CSS After being transformed with the xsl file, the resulting xml file is still very elementary. More formatting can be done in the xsl, but I prefer to attach a css file to create the final polished look. View the complete css file herehere