Website Development & Management Getting Started with Databases Instructor: John Seydel, Ph.D. CIT 3353 -- Fall 2006 www.clt.astate.edu/jseydel/mis3353.

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
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.
What is MySQL? MySQL is a relational database management system (A relational database stores data in separate tables rather than putting all the data.
PHP (2) – Functions, Arrays, Databases, and sessions.
Website Development & Management More PHP Odds & Ends Instructor: John Seydel, Ph.D. CIT Fall
PHP and MySQL PHP for the Web, page PHP and MySQL MySQL Resource PHP – MySQL Resource
Objectives Connect to MySQL from PHP
Website Development & Management Getting Ready for the Server-Side CIT Fall Instructor: John Seydel, Ph.D.
MySQL and PHP By Trevor Adams.
Website Development & Management PHP Odds & Ends Instructor: John Seydel, Ph.D. CIT Fall
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.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
MIS2502: Data Analytics MySQL and SQL Workbench David Schuff
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Website Development & Management PHP Fundamentals CIT Fall Instructor: John Seydel, Ph.D.
SJSU CS157B Dr. Lee1  2004 Jenny Mitchell Two Useful Tools You Can’t Live Without by Jenny Mitchell SJSU CS157B Section PHP and MySQL.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
Website Development & Management Getting to Know HTML Better CIT Fall Instructor: John Seydel, Ph.D.
INTERNET APPLICATION DEVELOPMENT For More visit:
MySQL + PHP.  Introduction Before you actually start building your database scripts, you must have a database to place information into and read it from.
Website Development & Management More PHP Fundamentals CIT Fall Instructor: John Seydel, Ph.D.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
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 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Week Four CIT 354 Internet II. 2 Objectives Uploading Files to Your Web Site Establishing a Connection Creating a Database Table Common Programming Errors.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
1 Working with MS SQL Server Textbook Chapter 14.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
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.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Installation and Testing.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
INTERNET APPLICATION DEVELOPMENT Practical on Sessions.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
Session 7: Getting PHP to Talk to MySQL. Objectives Connecting to the Database Building & Executing the SQL SELECT Query Fetching & Displaying the data.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Electronic Commerce Server-Side Scripting Exercises MIS Spring 2006 Instructor: John Seydel, Ph.D.
PHP Database Processing CIS 1715 Web Technologies.
Website Development & Management Going Live with Web Pages (a) CIT Fall Instructor: John Seydel, Ph.D.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Website Development & Management A PHP Exercise CIT Fall Instructor: John Seydel, Ph.D.
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)
Apache, MySQL and PHP Installation and Configuration Chapter 2 MySQL Installation and Configuration.
Database Access Using JDBC BCIS 3680 Enterprise Programming.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
What is MySQL? MySQL is a relational database management system (RDBMS) based on SQL (Structured Query Language). First released in January, Many.
CSC 405: Web Application Engineering II8.1 Web programming using PHP What have we learnt? What have we learnt? Underlying technologies of database supported.
Website Development & Management Some Wrap-Up Items Instructor: John Seydel, Ph.D. CIT Fall
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Setting up a Development Environment. What you need Webserver (Apache) Database (MySQL) PHP All in Uniserver (google “uniserver”) Download the windows.
MYSQL AND MYSQL WORKBENCH MIS2502 Data Analytics.
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Chapter 8 Working with Databases and MySQL
Presentation transcript:

Website Development & Management Getting Started with Databases Instructor: John Seydel, Ph.D. CIT Fall

Student Objectives Upon completion of this class meeting, you should be able to: Interact directly with MySQL to  Start the database server  Manage users  Create databases  Work with database tables Create Insert rows Display information Summarize basic database concepts Write basic PHP scripts that connect to MySQL databases and display database info

Data Management Fundamentals Review of the logical organization of data Field: characteristic of the entity involved (column) Record: collection of fields for a specific entity (row) File: collection of records for a given entity type (table) Database: collection of related files Typical data management operations Sort Query Update Purpose: raw data  information (reports) Typically done via some interface Direct interaction with DBMS Applications program calls to DBMS  Desktop applications  Web applications (via PHP)

Review: The Installation Process for MySQL Generally follows procedure given in Meloni textbook Download mysql win.zip from course Handouts page (or from MySQL.com) into Downloads directory Uncompress into a default temporary directory and then open that directory Double-click on SETUP.EXE and accept all defaults as the installation wizard runs Test the installation Run c:\mysql\bin\winmysqladmin.exe Provide a username and password you’ll remember (generally, these won’t be used again, ever) Note the stoplight now on taskbar at bottom right MySQL’s database server now starts upon bootup Now, some followup...

Now: Completing the MySQL Setup Note the following clarifications, as well as corrections to errors in the textbook MySQL executables are located in c:\mysql\bin (not c:\mysqlbin) Initial startup for the MySQL database server Use the WinMySQLAdmin interface (not simply c:\mysql\bin)  Starts the database server for the first time  Creates a userID and password (typically not used again) From then on MySQL will start automatically at boot time You must create a database user (in DOS window) before working with any databases (see Chapter 11, pp ) mysql –u root -p USE mysql; GRANT ALL ON *.* TO IDENTIFIED BY “psw”; To ensure things are working, create a database CREATE DATABASE testDB;(do not need to run mysqladmin) When done with MySQL QUIT;

How MySQL Stores the Data Each table (i.e., relation) involves three files: TableName.frm TableName.MYD (where the actual data are) TableName.MYI The files for all the tables belonging to a given database are stored in a directory with the same name as the database All database directories are stored in the data directory within c:\mysql Note: upon completion of the MySQL installation process, there are two databases mysql  Stores system info (users, permissions, etc.)  Do not mess with this test (this is initially empty, and anyone can access it without login)

Working with MySQL Get started mysql -u jojobeans –p USE testDB; SHOW TABLES; Using tables CREATE TABLE tblTest (testID int, testNote text); EXPLAIN tblTest; SELECT * FROM tblTest; INSERT INTO tblTest VALUES (123,’First entry’); INSERT INTO tblTest VALUES (456,’Second entry’); SELECT * FROM tblTest; QUIT;

Using PHP to Interface with MySQL Making sure MySQL works with PHP In php.ini: uncomment extension=php_mysql.dll Copy c:\php\ext\php_mysql.dll into c:\windows  New Always starts with the creation of a connection Requires opening a database Generally involves generating a recordset (aka, result set) Processing records typically involves some sort of looping construct One repetition per record Must be controlled by some sort of counter: foreach(), while(), and for() Makes use of several important functions...

PHP Functions: Processing Basic Queries mysql_connect() Arguments (string): server, userID, password Returns a string (connection information) mysql_select_db() Arguments (string): database to be used, connection Returns a boolean value mysql_query() Arguments (string): SQL query, connection Returns a recordset (an array of data) mysql_num_rows() Argument (array): recordset Returns an integer (number of records) mysql_fetch_array() Arguments (string): recordset Returns a row from the recordset

Demonstration: Listing FKAuto’s Inventory The database: fkauto One table at present: UsedCars Write a script to access the data and create a web page displaying a bullet list with make, model, year, mileage, and price for each carscript

What We’ve Seen New PHP functions mysql_connect() mysql_select_db() mysql_query() mysql_num_rows() mysql_fetch_array() A little SQL Used directly with MySQL Incorporated into PHP script The for() construct How to use PHP to connect to MySQL, open a database, create a recordset, and process that recordset How/where MySQL files are stored

The FKAuto Database Files For use on your own computer: Download these Available in the Documents directory (not public_html) of the cit3353 account on SuSE1  Recall the password?  All three files for the UsedCars database are in a directory named fkauto For use on SuSE1: don’t worry about where they are, as they are available to your scripts However, the “owner” is user cit3353 Thus use the appropriate values for user and password