NMED 3850 A Advanced Online Design January 14, 2010 V. Mahadevan.

Slides:



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

PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.
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 25, 2010 V. Mahadevan.
Faculty of Sciences and Social Sciences HOPE PHP & MySQL Stewart Blakeway FML 213
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
ADVM420- Class #4 Web Design with PHP and MySQL Adding and Listing from a MySQL Database.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
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.
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Class 3 MySQL Robert Mudge Reference:
1 Chapter 8 – Working with Databases spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
Slide 8-1 CHAPTER 8 Using Databases with PHP Scripts: Using MySQL Database with PHP.
INTERNET APPLICATION DEVELOPMENT For More visit:
In the next lectures you will learn  What is SQL  How to access mySQL database  How to create a basic mySQL database  How to use some basic queries.
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
 Mysql – popular open-source database management system  PHP usually works with Mysql for web- based database applications  LAMP applications—Web-based.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
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.
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.
PHP MySQL. SQL: Tables CREATE TABLE tablename { fieldname type(length) extra info,... } Extra info: –NULL (allows nulls in this field) –Not NULL (null.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
MySQL PHP Web Technology. Logging in to Command Line Start -> Programs -> AppServ -> MySQL Command Line Client Enter Password, then you’ll be working.
CSC 2720 Building Web Applications Database and SQL.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Selecting Data.
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
What’s a database? Data stored in a structured format that lends itself to easy manipulation and recall.
PHP and Mysql Database. PHP and Database Mysql – popular open-source database management system PHP usually works with Mysql for web-based database applications.
THE WEBMASTERS: SENG + WAVERING.  On account of construction, we will be having class in room 1248 next week.
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
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.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
MySQL. Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with.
PHP: MySQL. PHP Connect to MySQL PHP 5 and later can work with a MySQL database using: – MySQLi extension (the "i" stands for improved) – PDO (PHP Data.
CHAPTER 10 PHP MySQL Database
CSC 2720 Building Web Applications Accessing MySQL from PHP.
Mysql YUN YEO JOONG. 1 Connecting to and Disconnecting from the Server 1 Connecting to and Disconnecting from the Server shell> mysql – h host -u user.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Intro to MySQL.
Introduction to Database Programming with Python Gary Stewart
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
CS242 SQL. What is SQL? SQL:  stands for Structured Query Language  allows you to access a database  is an ANSI standard computer language  can execute.
PHP & MY SQL Instructor: Monireh H. Sayadnavard 1.
3 A Guide to MySQL.
PHP: MySQL Lecture 14 Kanida Sinmai
CS320 Web and Internet Programming SQL and MySQL
Open Source Server Side Scripting Permissions & Users
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
Introduction to Web programming
PHP: Database connection
CS3220 Web and Internet Programming SQL and MySQL
MySQL Database System Installation Overview SQL summary
PHP AND MYSQL.
CS3220 Web and Internet Programming SQL and MySQL
Introduction to Web programming
JDBC II IS
Presentation transcript:

NMED 3850 A Advanced Online Design January 14, 2010 V. Mahadevan

SQL Data Types Various kinds of data can be stored in a relational database. Each data item has a particular type. Examples: INT: integers CHAR: alphanumeric characters (up to 30) VARCHAR: alphanumeric characters (up to 255) FLOAT: real numbers DATE: YYYY-MM-DD DATETIME: YYYY-MM-DD HH:mm:SS

SQL Data Types (cont.) CREATE TABLE Person (person_id INT, last_name VARCHAR(20), first_name VARCHAR(20), age INT, bday DATE); INSERT INTO Person VALUES (1, 'Smith', 'Bob', 30, ' ');

SQL Data Types (cont.) Some useful MySQL date functions: CURDATE(): returns the current date NOW(): returns the current date and time CREATE TABLE Datetest (the_date DATE, the_date_time DATETIME); INSERT INTO Datetest VALUES (CURDATE(), NOW()); CURDATE(): returns the current date. NOW(): returns the current date and time.

SQL Data Types (cont.) Date types can be compared using SQL: SELECT * FROM Person WHERE bday > ‘ ’; This is a very powerful feature.

First Web Form Last Name: First Name: Age:

First PHP Script You entered Last Name: You entered First Name: You entered Age: ………

Inserting Data into MySQL <?php $hostname = 'localhost'; $username = 'newmedia'; $password = 'newmedia'; $connection = mysql_connect($hostname, $username, $password) or die ('Connection error!!!'); $database = 'peopledb'; mysql_select_db($database); $lastname = $_POST["last_name"]; $firstname = $_POST["first_name"]; $age = (int)$_POST["age"];

Inserting Data into MySQL (cont.) print " Inserted the following data into the MySQL Database: "; print " Last Name: $lastname "; print " First Name: $firstname "; print " Age: $age "; $execute_statement = "INSERT INTO person(last_name, first_name, age) VALUES ('$lastname', '$firstname', '$age')"; mysql_query($execute_statement) or die ('Error executing SQL statement!!!'); ?>

Retrieving Data from MySQL $lastname = $_POST["last_name"]; print " Retrieved the following data from the MySQL Database based on last name = $lastname: "; $execute_statement = "SELECT * FROM person WHERE last_name='$lastname'"; $results = mysql_query($execute_statement) or die ('Error executing SQL statement!!!'); while($item = mysql_fetch_array($results)) { print $item['last_name']; print " "; print $item['first_name']; print " "; print $item['age']; print " "; }

Updating Data in MySQL $oldlastname = $_POST["old_last_name"]; $newlastname = $_POST["new_last_name"]; print " Updated oldlastname = $oldlastname to newlastname = $newlastname : "; $execute_statement = "UPDATE person SET last_name = '$newlastname' WHERE last_name='$oldlastname'"; mysql_query($execute_statement) or die ('Error executing SQL statement!!!');

Deleting Data from MySQL $lastname = $_POST["last_name"]; print " Deleted lastname = $lastname from database "; $execute_statement = "DELETE FROM person WHERE last_name = '$lastname'"; mysql_query($execute_statement) or die ('Error executing SQL statement!!!');

References  MySQL 5.0 Reference Manual:  PHP Manual: