PHP and MySQL CS380 1. How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.

Slides:



Advertisements
Similar presentations
Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.
Advertisements

PHP (2) – Functions, Arrays, Databases, and sessions.
What is it? –Large Web sites that support commercial use cannot be written by hand What you’re going to learn –How a Web server and a database can be used.
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
Designing a Database Unleashing the Power of Relational Database Design.
Multiple Tiers in Action
PHP and MySQL Web Development tMyn1 PHP and MySQL Web Development When you install PHP, you can select from a number of extensions. The MySQL support in.
Page 1 ISMT E-120 Introduction to Microsoft Access & Relational Databases The Influence of Software and Hardware Technologies on Business Productivity.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Appendix A Database Design CS Database design principles  database design: the act of deciding the schema for a database  database schema: a description.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
Server-side Scripting Powering the webs favourite services.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Simple Database.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Databases. Database A database is an organized collection of related data.
PHP meets MySQL.
1 Accelerated Web Development Course JavaScript and Client side programming Day 2 Rich Roth On The Net
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Example simpsons database
SQL Queries Relational database and SQL MySQL LAMP SQL queries A MySQL Tutorial and applications Database Building Assignment.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
Database Normalization Lynne Weldon July 17, 2000.
SQL Queries Relational database and SQL MySQL LAMP SQL queries A MySQL Tutorial and applications Database Building.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
SQL 101 for Web Developers 14 November What is a database and why have one? Tables, relationships, normalization SQL – What SQL is and isn’t – CRUD:
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
CSE 154 LECTURE 14: MULTI-TABLE SQL QUERIES (JOINS)
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
HTML, PHP, and MySQL: Putting It All Together. Making a Form Input tags Types: “text” “radio” “checkboxes” “submit”
Creating PHPs to Insert, Update, and Delete Data CS 320.
2010/11 : [1]PHP with MySQLBuilding Web Applications using MySQL and PHP (W1) PHP with MySQL.
Access Review. Access Access is a database application A database is a collection of records and files organized for a particular purpose Access supports.
Security Considerations Steve Perry
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Microsoft FrontPage 2003 Illustrated Complete Integrating a Database with a Web Site.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Chapter 10 Database Management. Data and Information How are data and information related? p Fig Next processing data stored on disk Step.
Windows 7 WampServer 2.1 MySQL PHP 5.3 Script Apache Server User Record or Select Media Upload to Internet Return URL Forward URL Create.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 1: Introduction to IS2803 Rob Gleasure
How Web Database Architectures Work CPS181s April 8, 2003.
Howard Paul. Sequential Access Index Files and Data File Random Access.
DATABASES.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Introduction to Database Programming with Python Gary Stewart
Databases.
CS320 Web and Internet Programming SQL and MySQL
PHP / MySQL Introduction
ISC440: Web Programming 2 Server-side Scripting PHP 3
Web Systems Development (CSC-215)
Chapter 8 Working with Databases and MySQL
Web Systems Development (CSC-215)
PHP and MySQL.
Server-Side Processing II
Data Management Innovations 2017 High level overview of DB
CS3220 Web and Internet Programming SQL and MySQL
Lecture 24: Creating a Database and More joins
CS3220 Web and Internet Programming SQL and MySQL
Lecture 22: Creating a Database and More joins
Presentation transcript:

PHP and MySQL CS380 1

How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP code (ex. results.php).  Web server receives the request.  Web server passes the file (results.php) to the PHP engine.  PHP engine parses the script.  PHP opens connection to MySQL server if needed.  PHP sends query to database server. CS380 2

How Web Site Architectures Work  Database server processes the query.  Database sends back results to PHP server.  PHP formats data that it received from database server nicely for HTML.  PHP engine finishes running script.  PHP returns HTML to the web server.  Web server passes HTML back to the browser. CS380 3

Querying a database from the web  Check and filter data coming from the user.  Setup connection to the appropriate database.  Query the database.  Retrieve the results.  Present the results back to user. CS380 4

PHP MySQL functions CS380 5

Other MySQL PHP functions CS380 6

Insert in a database  Insert new values to columns of a table CS380 7 INSERT INTO tbl_name (col1,col2) VALUES(15,col1*2); SQL $isbn=$_POST['isbn']; $author=$_POST['author']; $title=$_POST['title']; $price=$_POST['price']; $query = "insert into books values ('".$isbn."', '".$author."', '".$title."', '".$price."')"; SQL

Practice: Bookorama  Query database using forms  Insert data in database CS380 8

Appendix A Database Design CS380 9

Database design principles  database design: the act of deciding the schema for a database  database schema: a description of what tables a database should have, what columns each table should contain, which columns' values must be unique, etc. CS380 10

Database design principles  some database design principles:  keep it simple, stupid (KISS)  provide an identifier by which any row can be uniquely fetched  eliminate redundancy, especially of lengthy data (strings)  integers are smaller than strings and better to repeat  integers can be compared/searched more quickly than strings, real numbers CS380 11

First database design  what's good and bad about this design?  good: simple (one table), can see all data in one place  bad: redundancy (name, , course repeated frequently)  bad: most searches (e.g. find a student's courses) will have to rely on string comparisons  bad: there is no single column whose value will be unique in each row 12

Second database design  splitting data into multiple tables avoids redundancy  normalizing: splitting tables to improve structure and remove redundancy / anomalies  normalized tables are often linked by unique integer IDs 13

Second database design  primary key: a table column guaranteed to be unique for each record  record in Student table with id of 888 is Lisa Simpson's student info 14 CS380

Second database design  records of one table may be associated with record(s) in another table  foreign key: a column in table A that stores a value of a primary key from another table B  records in Grade table with student_id of 888 are Lisa Simpson's course grades 15

Design question  suppose we want to keep track of the teachers who teach each course  e.g. Ms. Krabappel always teaches CSE 142 and INFO 100  e.g. Ms. Hoover always teaches CSE 143  e.g. Mr. Stepp always teaches CSE 190M  what tables and/or columns should we add to the database? 16

Design answer  add a teachers table containing information about instructors  link this to courses by teacher IDs  why not just skip the teachers table and put the teacher's name as a column in courses?  repeated teacher names are redundant and large in size 17