>> PHP: MySQL & CRUD. R ecall Database Tables Records is composed of Operations (CRUD) Create Retrieve Update Delete DBMS Access Control MySQL phpMyAdmin.

Slides:



Advertisements
Similar presentations
PHP: Date() Function The PHP date() function formats a timestamp to a more readable date and time.
Advertisements

PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
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 5 + MySQL 5 A Perfect 10. Adam Trachtenberg PHP 5 + MySQL 5 = A Perfect mysqli extension i is for improved! All new MySQL extension for PHP.
Keys, Referential Integrity and PHP One to Many on the Web.
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.
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
PHP Programming. Topics Background and History of PHP Installation Comments in PHP Variables Conditions Loops Functions File Handling Database Handling.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
CSCI 6962: Server-side Design and Programming
1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record.
LIS651 lecture 7 PHP mySQL Thomas Krichel
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 &
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
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.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Lec_6 Manipulating MySQL Databases with PHP PHP Programming with MySQL.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
Polling System Part 1 Creating PHP & MySQL Files CIS 254.
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.
PHP Part 2.
Lecture 10 – MYSQL and PHP (Part 2)
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
PHP with MySQL 1.
Internet Information Systems Writing to Databases and Amending Data.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
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.
2010/11 : [1]PHP with MySQLBuilding Web Applications using MySQL and PHP (W1) PHP with MySQL.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
Visual Programing SQL Overview Section 1.
PHP on a Fast Track a quick introduction to PHP programming by Jarek Francik last time updated in 2012.
THE WEBMASTERS: SENG + WAVERING.  On account of construction, we will be having class in room 1248 next week.
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.
>> PHP: Insert Query & Form Processing. Insert Query Step 1: Define Form Variables Step 2: Make DB Connection Step 3: Error Handling Step 4: Define the.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
PHP and SQL Server: Connection IST2101. Typical web application interaction (php, jsp…) database drivers 2IST210.
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 Programming. Topics Database Handling (MySQL, MSSQL, ODBC)
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.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
>> PHP: File Uploads. Pre-requisite Go Online – Download file modify-item.php – copy it to your root folder (D:\xampp\htdocs\Buy4mMe) Web-Based Systems.
CHAPTER 10 PHP MySQL Database
CSC 2720 Building Web Applications Accessing MySQL from PHP.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
MySQL MySQL and PHP – interacting with a database.
Software-Projekt 2008 Seminarvortrag“Short tutorial of MySql“ Wei Chen Verena Honsel.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
PHP (Session 2) INFO 257 Supplement.
Databases.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Design and Development
Introduction to Web programming
ISC440: Web Programming 2 Server-side Scripting PHP 3
PHP: Database connection
Introduction to Web programming
Presentation transcript:

>> PHP: MySQL & CRUD

R ecall Database Tables Records is composed of Operations (CRUD) Create Retrieve Update Delete DBMS Access Control MySQL phpMyAdmin Web-Based Systems - Misbhauddin 2

phpMyAdmin Click Here Web-Based Systems - Misbhauddin 3

Collation character set is a set of symbols and encodings Collation is a set of rules for comparing characters in a character set In latin9, there are letters as e é è ê f If sorted by their binary representation, it will go "e f é ê è" MySQL can do these things for you: Store strings using a variety of character sets Compare strings using a variety of collations Mix strings with different character sets or collations in the same server, the same database, or even the same table Enable specification of character set and collation at any level Web-Based Systems - Misbhauddin 4

Database Operations Create User Create Database Create Table Insert Records in the Table DEMO Web-Based Systems - Misbhauddin 5

Database Connection from PHP Pre-requisite – Create a new file in your project – Name it connection-db.php WHY? – To avoid typing the database connection commands in PHP each time we connect Remember – HTTP is a stateless protocol Procedure to connect to the database Step 1: Create and initialize the required connection variables Host-Name ($host = ‘localhost’;) User Name ($user = ‘your-username’;) Password ($pwd = ‘your-password’;) Database Name ($db = ‘store’;) Web-Based Systems - Misbhauddin 6

Database Connection from PHP Step 2: Create the connection variable $con = mysqli_connect($host,$user,$pwd,$db); Step 3: Check for success & failure (optional) if(mysqli_connect_errno($con)) { echo mysqli_connect_error(); } Step 4: Include this connection file inside any php file that needs connection to the database Web-Based Systems - Misbhauddin 7

Running a Query Process to Construct & Run a MySQL Query Step 1: Construct the query, preferably in a variable $query = ‘SELECT * FROM stuff’; Step 2: Run the Query $result = mysqli_query($con, $query); Step 3: Fetch the Results (In a regular array): mysqli_fetch_array($result) (In an associative array): mysqli_fetch_assoc($result) Web-Based Systems - Misbhauddin 8

Issues with result processing Step 3: Fetch the Results (In a regular array): mysqli_fetch_array($result) (In an associative array): mysqli_fetch_assoc($result) Result is returned row-by-row AND foreach loop statement in PHP requires the complete array at a time Solution? Web-Based Systems - Misbhauddin 9 Hint: Is for each necessary inside the while loop? Maybe not. ☻

Issues with result processing Step 3: Fetch the Results (In a regular array): mysqli_fetch_array($result) (In an associative array): mysqli_fetch_assoc($result) Result is returned row-by-row AND foreach loop statement in PHP requires the complete array at a time Solution while ($row = mysqli_fetch_assoc($result)) { $stuff[$row[‘ID’]] = array( "name" => $row[‘Name’], "img" => $row[‘Image’], "price" => $row[‘Price’] ); } 10 Web-Based Systems - Misbhauddin

Next on Web-based Systems Web-Based Systems - Misbhauddin 11 Next Class – Form Handling in PHP – Add Items to the Database