Integrating Databases into the Web with PHP/MySQL CS 4000.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
Advertisements

CC SQL Utilities.
RETRIEVING DATA FROM FCC LICENSE DATABASE Steps for obtaining query results, and importing it into MS Excel Spreadsheet.
What is MySQL? MySQL is a relational database management system (A relational database stores data in separate tables rather than putting all the data.
Quick-and-dirty.  Commands end in a semi-colon ◦ If you forget, another prompt line shows up  Either continue the command or…  End it with a semi-colon.
PHP (2) – Functions, Arrays, Databases, and sessions.
Chapter 7 Data Management. Agenda Database concept Import data Input and edit data Sort data Function Filter data Create range name Calculate subtotal.
7/2/2015Murali Mani -- CS5421 Database Management Systems DB Application Development Project Statement + Introduction to Oracle.
Creating Database Tables CS 320. Review: Levels of data models 1. Conceptual: describes WHAT data the system contains 2. Logical: describes HOW the database.
Database Design IST 7-10 Presented by Miss Egan and Miss Richards.
Pasewark & Pasewark 1 Access Lesson 6 Integrating Access Microsoft Office 2007: Introductory.
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
MySql In Action Step by step method to create your own database.
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
BIS121 IT for Business Application Lecture 8 – Database (Part I)
Simple Pages for Omeka Lauren Dzura LIS
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Tutorial 10 Adding Spry Elements and Database Functionality Dreamweaver CS3 Tutorial 101.
Chapter 10: Working with Large Data Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Class #2: Introduction to MySQL (Continued) Where clause (continued) Aggregate Functions Creating users Backing up your database Indexes (if time) Importing.
MySQL + PHP.  Introduction Before you actually start building your database scripts, you must have a database to place information into and read it from.
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
Importing existing reference lists Lorraine Beard & Martin Snelling DRAFT: May 2007.
Website Development with Dreamweaver
Python MySQL Database Access
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
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.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Introduction to Internet Databases MySQL Database System Database Systems.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Installation and Testing.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Week 7. Lecture 2 Functions, Arrays, PHP&MySQL. Function with More than one argument and a return statement For a function to return a value, the return.
Colleague, Excel & Word Best of Friends Presented by: Joan Kaun & Yvonne Nelson College of the Rockies.
Most information comes from Chapter 3, MySQL Tutorial: 1 MySQL: Part.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
HTML ( HYPER TEXT MARK UP LANGUAGE ). What is HTML HTML describes the content and format of web pages using tags. Ex. Title Tag: A title It’s the job.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
ECDL. Word processing Work with documents and save them in different file formats Choose built-in options such as the Help function to enhance productivity.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
MySQL Importing and creating a database. CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which.
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
A table is a set of data elements (values) that is organized using a model of vertical columns (which are identified by their name) and horizontal rows.
Microsoft Access 2000 Creating Queries, Reports and Web Pages.
CS 111 – Nov. 8 Databases Database Management Systems (DBMS) Structured Query Language (SQL) Commitment –Please review sections 9.1 – 9.2.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
CHAPTER 7 LESSON C Creating Database Reports. Lesson C Objectives  Display image data in a report  Manually create queries and data links  Create summary.
DATABASES.
ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: Week 3 – MySQL – Statements.
Introduction to Database Programming with Python Gary Stewart
Web Database Programming Using PHP
MySQL Installation Tarik Booker CS 122.
Databases.
Presented by: Teererai Marange
Easily retrieve data from the Baan database
Web Database Programming Using PHP
Intro to PHP & Variables
Principles of report writing
ENDNOTE Software – The Basics
Database Instructor: Bei Kang.
Presentation transcript:

Integrating Databases into the Web with PHP/MySQL CS 4000

Getting Started PHP and MySQL are a powerful team for developing fully interactive database-driven Web sites. Starting with a Web server (like Apache), you simply download and install MySQL and then download and install and configure PHP on the server (in that order).

Intro to MySQL Once you have MySQL and PHP installed and configured for your server, you need to create the database to hold the information for your application. Go into the mysql folder on your server, then into the bin folder and type mysql. This begins the MySQL command interpreter (your command line prompt will change to “mysql>”).

Creating a database You can see what databases currently exist on the server with the command: –SHOW DATABASES; To create a database, use the command “CREATE DATABASE” followed by the name of the database you want to create (simple, huh?). For example, to create a database to hold information on employees, you could type: –CREATE DATABASE employdb;

Selecting a Database for Use You must then select the database so that you can enter data into it. To do this, use the USE command: –USE employdb; Now you have created a database and selected it for use.

Tables for Data The next step is putting in some information to use in your queries for your Web page. This is done in the form of tables. You can see the tables associated with your database by using the SHOW command: –SHOW TABLES; But, since you just created your database, there are no tables yet associated with your database.

Creating Tables of Data To create one or more tables for your database, you should first consider carefully –what kind of information you want to include in the table, as well as –the field type and length of each data element.

Creating Tables For example, to create a table named “emp_position” in the above database, with fields for employee number (9 characters), job title (20 characters), job code (an integer), and hourly pay rate (a decimal value), we could do the following: –CREATE TABLE emp_position (emp_num VARCHAR(9), jbtitle VARCHAR(20), job_code INT, hrly_rate FLOAT);

Adding Data to Tables To verify that your table was successfully created, type DESCRIBE emp_position;. Now you are ready to import data into your database. If you are starting a table from scratch, create a simple text file with tabs separating the values on each line, as below: Janitorial Staff ICAPP Professor Web Designer

Adding Data cont. With each column corresponding to the order in our table, we would have an employee # who is a member of the Janitorial Staff, job code 1142, whose hourly pay rate is $11.50, and so on. Save this text file as EmployeePositionList.txt, for example.

Loading Data into a Table Once you have created a “tab-delimited” text file (tabs separate the fields on a row), use the LOAD command to load the data into the database: –LOAD DATA LOCAL INFILE “EmployeePositionList.txt” INTO TABLE emp_position; All of the data in the text file will be put into the table. If you are starting with a spreadsheet or other file of information that you need to import into the database, format it as a text document with tab delimiters and follow the procedure above.

Inserting Rows One at a Time You may also insert rows one-by-one, using the INSERT command: –INSERT INTO emp_position VALUES (‘ ’, ‘ICAPP Student’, ‘3131’, ‘100.00’); While you might not want to enter many values this way at the command prompt, a good use for this is to insert values from a form into a Web database using PHP, as is covered in the PHP section.

Retrieving Information: SELECT To retrieve information from a database table, the SELECT statement is used. A general form of the statement is: –SELECT fields_to_show FROM name_of_table WHERE condition_needed ORDER BY field_name_to_sort_by;

SELECTing rows & columns So, to show all fields from the emp_position table for employees whose pay rate is over $10.00 per hour, sorted by pay rate, we would use: –SELECT * FROM emp_position WHERE hrly_rate>10.00 ORDER BY hrly_rate; That should be just enough mySQL to give us what we need to do the database interface in PHP.

Next Time We’ll talk about PHP