PHP MySQL1 PHP and MySQL After this lecture, you should be able to:  Access a MySQL database with PHP  mysql_connect()  mysql_select_db()  mysql_query()

Slides:



Advertisements
Similar presentations
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.
Advertisements

PHP Week 11 INFM 603. Thinking About PHP Local vs. Web-server-based display HTML as an indirect display mechanism “View Source” for debugging –But not.
E-Invoice System CS541 Database Systems Class Project By: Parul Gupta.
© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University
PHP and MySQL PHP for the Web, page PHP and MySQL MySQL Resource PHP – MySQL Resource
Objectives Connect to MySQL from PHP
Multiple Tiers in Action
MySQL and PHP By Trevor Adams.
Website Development & Management PHP Odds & Ends Instructor: John Seydel, Ph.D. CIT Fall
Intermediate PHP & MySQL
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.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
PHP-MySQL By Jonathan Foss. PHP and MySQL Server Web Browser Apache PHP file PHP MySQL Client Recall the PHP architecture PHP can communicate with a MySQL.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
Programming with php By: Seth Larson. A little bit about PHP  PHP stands for PHP:  Hypertext Preprocessor  PHP is a widely-used general-purpose server-side.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Class 3 MySQL Robert Mudge Reference:
Application Sketch home.htm delete.php updateform.php display.php insert.php insertform.htm update.php Data Base Hyperlink Information exchange with database.
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.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
10/09/2015 E.R.Edwards 10/09/2015 Staffordshire University School of Computing Easy PHP F Available from -
PHP – MySQL Extensions. Table used in most examples CREATE TABLE product ( rowID INT NOT NULL AUTO_INCREMENT, productid VARCHAR(8) NOT NULL, name VARCHAR(25)
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 19: Database Support.
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.
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.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
MySQL PHP Web Technology. Logging in to Command Line Start -> Programs -> AppServ -> MySQL Command Line Client Enter Password, then you’ll be working.
Polling System Part 1 Creating PHP & MySQL Files CIS 254.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
PHP Part 2.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
Lecture 10 – MYSQL and PHP (Part 2)
Technology & Management Club Development Software Overview.
Database Access with PHP and MySQL CS356 Examples from Web Database Applications, by Hugh E. Williams & David Lane, O'Reilly, 2002.
MySQL Database Connection
PHP - MySQL Connection 8 March 2006 Adina Crainiceanu IT420: Database Management and Organization.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
Login to a Database (from a Webpage), Inserting data into a database from a form, getting data from database and display on Webpage Done by: Mashail Alsolamy.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
PHP Database Processing CIS 1715 Web Technologies.
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.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
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.
Accessing mySQL relational database. MySQL database.  Today, we will attempt and open a connection to the MySQL server.  We need to specify the database.
 Connectivity Function :-  mysql_connect ()  mysql_select_db ()  mysql_query ()  mysql_nam_rows ()  mysql_fetch_row ()  mysql_affected_rows () 
Database MySQL Universitas Muhammadiyah Surakarta Yogiek Indra Kurniawan.
LECTURE 3 MYSQL Database. PHP MYSQL CONNECTION MySQL is a database system used on the web MySQL is a database system that runs on a server MySQL is ideal.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
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.
CSC 2720 Building Web Applications Accessing MySQL from PHP.
Setting up a Development Environment. What you need Webserver (Apache) Database (MySQL) PHP All in Uniserver (google “uniserver”) Download the windows.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Introduction to Dynamic Web Programming
Chapter 9 Using PHP with MySQL.
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP and MySQL.
Accessing Your MySQL Database from the Web with PHP (Ch 11)
PHP: Database connection
Web Programming– UFCFB Lecture
PHP AND MYSQL.
Introduction to Web programming
Presentation transcript:

PHP MySQL1 PHP and MySQL After this lecture, you should be able to:  Access a MySQL database with PHP  mysql_connect()  mysql_select_db()  mysql_query()  mysql_fetch_array()  mysql_fetch_object()  Complete the Assignment 5.

PHP MySQL2 6 Client Browser 1 PHP Module 3 4 Apache Web Server Accessing a MySQL Database with a PHP Script DB 2 5 MySQL

PHP MySQL3 MySQL Functions  Prefixed with mysql_  mysql_connect()  mysql_select_db()  mysql_query()  etc. 

PHP MySQL4 Connecting to a Database <?php $connect = mysql_connect (“mysql.cs.orst.edu", "name", "password") if(!$connect) die("Unable to connect\n"); mysql_select_db(“my_database”) ?>

PHP MySQL5 Common Include File: common.inc <?php define("DB_SERVER", "mysql.cs.orst.edu"); define("DB_USER", “my_database_user_name"); define("DB_PASSWORD", “my_password"); define("DB_NAME", “my_database_name"); $connect = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die ("Unable to connect to server \n"); mysql_select_db(DB_NAME) or die ("Unable to select database". DB_NAME. " \n"); echo "Connected to database!”; ?>

PHP MySQL6 Retrieving Records $query = "select * from s"; $result = mysql_query($query);

PHP MySQL7 Displaying Retrieved Records while ($record = mysql_fetch_array($result)) { echo “Supplier Number: “. $record[‘sno’]. “\n”; echo “Supplier Name: “. $record[‘sname’]. “\n”; echo “Supplier Status: “. $record[‘status’]. “\n\n”; } Connected to database! Supplier Number: s1 Supplier Name: Smith Supplier Status: 20 Supplier Number: s2 Supplier Name: Jones Supplier Status: 10 …

PHP MySQL8 Displaying Retrieved Records while ($record = mysql_fetch_object($result)) { echo “Supplier Number: $record->sno\n”; echo “Supplier Name: $record->sname\n”; echo “Supplier Status: $record->status\n\n”; }

PHP MySQL9 Inserting a Record $query = "insert into s(sno, sname) values(‘s10', ‘Bose’); $result = mysql_query($query); if (!$result) { echo “Insertion failed”; }

PHP MySQL10 Updating Records $query = "update s set city = ‘Albany' where sname = ‘Bose'"; $result = mysql_query($query); if (!$result) { echo “Update failed”; }

PHP MySQL11 Deleting Records $query = "delete from s where status < 20"; $result = mysql_query($query); if (!$result) { echo “Deletion failed”; }

PHP MySQL12 Example: get_menu() <?php function get_menu() { $query = "select * from item;"; $result = db_query($query); while($arr = mysql_fetch_array($result)) { $menu[$arr['item_id']] = $arr; } return $menu; } ?>

PHP MySQL13 Example: get_item() <?php function get_item($item_id) { $query = "select * from item where item_id = ". $item_id; $result = db_query($query); $item = mysql_fetch_array($result); return $item; } ?>