Databases.  Multi-table queries  Join ▪ An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them. 

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Introduction to Ajax.
JQUERY/AJAX ALIREZA KHATAMIAN DELARAM YAZDANSEPAS.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
JavaScript & jQuery the missing manual Chapter 11
Chapter 5 Java Script And Forms JavaScript, Third Edition.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Server-side Scripting Powering the webs favourite services.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
HTML5 Communication. The Setup Somewhere on the web, a server makes a ”service” available, that we wish to use in a web application The service may offer.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Cross Site Integration “mashups” cross site scripting.
Using Client-Side Scripts to Enhance Web Applications 1.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
Web Development 101 Presented by John Valance
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
Chapter 16: Ajax-Enabled Rich Internet Applications with XML and JSON TP2543 Web Programming Mohammad Faidzul Nasrudin.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
AJAX. Overview of Ajax Ajax is not an API or a programming language Ajax aims to provide more responsive web applications In normal request/response HTTP.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
INFANL01-3 ANALYSE 3 WEEK 3 March 2015 Institute voor Communication, Media en Informatietechnology.
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
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,
JQUERY AND AJAX
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
JavaScript and Ajax Week 10 Web site:
Web Services Essentials. What is a web service? web service: software functionality that can be invoked through the internet using common protocols like.
JQuery form submission CIS 136 Building Mobile Apps 1.
JQuery, JSON, AJAX. AJAX: Async JavaScript & XML In traditional Web coding, to get information from a database or a file on the server –make an HTML form.
11 jQuery Web Service Client. 22 Objectives You will be able to Use JSON (JavaScript Object Notation) for communcations between browser and server methods.
LEC-8 SQL. Indexes The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading.
CSE 154 Lecture 11: AJAx.
Not a Language but a series of techniques
Data Virtualization Tutorial… CORS and CIS
AJAX.
CSE 154 Lecture 11: AJAx.
Session V HTML5 APIs - AJAX & JSON
CSE 154 Lecture 22: AJAX.
Web Browser server client 3-Tier Architecture Apache web server PHP
Ajax and JSON (jQuery part 2)
jQuery form submission
HTML Level II (CyberAdvantage)
PHP.
HTML5 AJAX & JSON APIs
JavaScript & jQuery AJAX.
Sending a text message (and more)
MIS JavaScript and API Workshop (Part 3)
Introduction to AJAX and JSON
Introduction to AJAX and JSON
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Sending a text message (and more)
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Presentation transcript:

Databases

 Multi-table queries  Join ▪ An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them.  Four different SQL JOINs ▪ INNER JOIN ▪ Returns all rows when there is at least one match in BOTH tables ▪ LEFT JOIN ▪ Return all rows from the left table, and the matched rows from the right table ▪ RIGHT JOIN ▪ Return all rows from the right table, and the matched rows from the left table ▪ FULL JOIN ▪ Return all rows when there is a match in ONE of the tables

 The most common type of join is: SQL INNER JOIN (simple join).  SQL INNER JOIN returns all rows from multiple tables where the join condition is met. SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name=table2.column_name

 Example: SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID

 The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2).  The result is NULL in the right side when there is no match. SELECT column_name(s) FROM table1 LEFT OUTER JOIN table2 ON table1.column_name=table2.column_name

 Example: SELECT Customers.CustomerName, Orders.OrderID FROM Customers LEFT JOIN Orders ON Customers.CustomerID=Orders.CustomerID ORDER BY Customers.CustomerName

 The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1).  The result is NULL in the left side when there is no match. SELECT column_name(s) FROM table1 RIGHT OUTER JOIN table2 ON table1.column_name=table2.column_name

 Example: SELECT Orders.OrderID, Employees.FirstName FROM Orders RIGHT JOIN Employees ON Orders.EmployeeID=Employees.EmployeeID ORDER BY Orders.OrderID

 The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the right table (table2).  The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins. SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name=table2.column_name

 Example: SELECT Customers.CustomerName, Orders.OrderID FROM Customers FULL OUTER JOIN Orders ON Customers.CustomerID=Orders.CustomerID ORDER BY Customers.CustomerName

 Data can be formatted using JSON (pronounced "Jason").  It looks very similar to object literal syntax, but it is not an object. ▪ It is just plain text data (not an object).  You cannot transfer the actual objects over a network. ▪ Rather, you send text which is converted into objects by the browser.

 Keys  In JSON, the key should be placed in double quotes (not single quotes).  The key (or name) is separated from its value by a colon.  Values  The value can be any of the following data types ▪ string ▪ Text (must be written in quotes) ▪ number ▪ Number ▪ Boolean ▪ Either true or false ▪ array ▪ Array of values - this can also be an array of objects ▪ object ▪ JavaScript object - this can contain child objects or arrays ▪ null ▪ This is when the value is empty or missing

{ "location": "San Francisco, CA", "capacity": 270, "booking" : true }  Each key/ value pair is separated by a comma.  However, note that there is no comma after the last key/value pair.

 JavaScript's JSON object can turn JSON data into a JavaScript object.  It can also convert a JavaScript object into a string.  JSON.stringify() converts JavaScript objects into a string, formatted using JSON. ▪ This allows you to send JavaScript objects from the browser to another application.  JSON.parse() processes a string containing JSON data. ▪ It converts the JSON data into a JavaScript objects ready for the browser to use.

{ "events": [ { "location": "San Francisco, CA", "date": "May 1", "map": "img/map-ca.png" }, { "location": "Austin, TX", "date": "May 15", "map": "img/map-tx.png" }, { "location": "New York, NY", "date": "May 30", "map": "img/map-ny.png" } ] }

 When JSON data is sent from a server to a web browser, it is transmitted as a string.  When it reaches the browser, your script must then convert the string into a JavaScript object. ▪ This is known as deserializing an object.  This is done using the parse () method of a built-in object called JSON. ▪ This is a global object, so you can use it without creating an instance of it first.  Once the string has been parsed, your script can access the data in the object and create HTML that can be shown in the page.  The JSON object also has a method called stringify(), which converts objects into a string using JSON notation so it can be sent from the browser back to a server. ▪ This is also known as serializing an object. ▪ This method can be used when the user has interacted with the page in a way that has updated the data held in the JavaScript object (e.g., filling in a form), so that it can then update the information stored on the server.

 $.get(url[, data][, callback][, type])  HTTP GET request for data  $.post(url[, data][, callback][, type])  HTTP POST to update data on the server  $.getJSON(url[, data][, callback])  Loads JSON data using a GET request  $.getScript(url[, callback])  Loads and executes JavaScript (e.g., JSONP) using a GET request  $  Shows that this is a method of the jQuery object.  url  Specifies where the data is fetched from.  data  Provides any extra information to send to the server.  callback  Indicates that the function should be called when data is returned (can be named or anonymous).  type  Shows the type of data to expect from the server.

$('#selector a').on('click', function (e) { e.preventDefault(); var queryString = 'vote=' + event.target.id; $.get('votes.php', queryString, function(data) { $('#selector').html(data) ; } ) ;

 You can load JSON data using the $.getJSON() method.  There are also methods that help you deal with the response if it fails.  Loading JSON  If you want to load JSON data, there is a method called $.getJSON() which will retrieve JSON from the same server that the page is from. ▪ To use JSONP you should use the method called $.getScript().

 Ajax and Errors  Occasionally a request for a web page will fail and Ajax requests are no exception. ▪ Therefore, jQuery provides two methods that can trigger code depending on whether the request was successful or unsuccessful, along with a third method that will be triggered in both cases (successful or not).  Success/Failure  There are three methods you can chain after $.get(), $.post(), $.getJSON(), and $.ajax() to handle success I failure. ▪.done() ▪ An event method that fires when the request has successfully completed ▪.fail() ▪ An event method that fires when the request did not complete successfully ▪.always() ▪ An event method that fires when the request has completed (whether it was successful or not)

$('#exchangerates').append(' '); function loadRates() { $.getJSON('data/rates.json').done( function(data){//SERVER RETURNS DATA var d =new Date();//Create date object var hrs= d.getHours();//Get hours var mins = d.getMinutes();//Get mins var msg = ' Exchange Rates ';//Start message $.each(data, function(key, val) {// Add each rate msg +=' ’ +key + ‘:’ + val + ' '; }); msg += ' Last update: ' + hrs + ':' + mins + ' ' ; // Show update time $('#rates').html(msg); //Add rates to page

}).fail(function() { //THERE IS AN ERROR $('aside').append('Sorry, we cannot load rates.'); //Show error message }).always(function() { //ALWAYS RUNS var reload = ' ' ; //Add refresh link reload += ' ' ; $('#reload').html(reload); //Add refresh link $('#refresh').on('click ', function(e) {//Add click handler e.preventDefault(); //Stop link loadRates(); // Call loadRates () }); } loadRates(); //Call loadRates()

 The $.ajax() method gives you greater control over Ajax requests.  Behind the scenes, this method is used by all of jQuery's Ajax shorthand methods.  Inside the jQuery file, the $.ajax() method is used by the other Ajax helper methods that you have seen so far (which are offered as a simpler way of making Ajax requests). ▪ This method offers greater control over the entire process, with over 30 different settings that you can use to control the Ajax request

 type  Can take values GET or POST depending on whether the request is made using HTTP GET or POST  url  The page the request is being sent to  data  The data that is being sent to the server with the request  success  A function that runs if the Ajax request completes successfully (similar to the.done() method)  error  A function that runs if there is an error with the Ajax request (similar to the.fail() method)  beforeSend  A function (anonymous or named) that is run before the Ajax request starts  complete  Runs after success/error events  timeout  The number of milliseconds to wait before the event should fail

 The settings can appear in any order, as long as they use valid JavaScript literal notation.  The settings that take a function can use a named function or an anonymous function written inline.  $.ajax() does not let you load just one part of the page so the jQuery.find() method is used to select the required part of the page.

$('nav a').on('click', function(e) { e.preventDefault(); var url = this.href;II URL to load var $content = $('#content');II Cache selection $('nav a.current').removeClass('current');//I Update links $(this).addClass('current'); $('#container').remove();II Remove content $.ajax({ type: "POST",II GET or POST url: url,II Path to file timeout: 2000,II Waiting time beforeSend: function() II Before Ajax $content.append(' Loading '); II Load message }, complete: function() { II Once finished $('#loading').remove(); II Clear message } success : function(data) { II Show content $content.html($(data).find('#container')).hide().fadeln(400); }, fail: function() { II Show error msg II Show error msg $('#panel').html(' Please try again soon. '); } }) ;