SlideShare a Scribd company logo
PHP 2
What is Database?
A database is an organized collection of data for
one or more purposes.
Where’s database data actually stored? Can I
see the files?
Database data is typically stored in files on a
hard disk although you could certainly look at
them.
Original Database
Relational Database use tables to store
information

Tables store data in a grid-like pattern of
columns and rows.
Php 2
MySQL
SQL is the query language used to communicate
with a MySQL database.
Tool to manage MySQL
SQL can be divided into two parts
     Data Manipulation Language (DML)
               SELECT
               UPDATE
               DELETE
               INSERT INTO
     Data Definition Language (DDL)
               CREATE DATABASE
               ALTER DATABASE
               CREATE TABLE
               ALTER TABLE
               DROP TABLE
               CREATE INDEX
               DROP INDEX
CREATE DATABASE
    CREATE DATABASE elvis_store
Php 2
CREATE TABLE INSIDE THE DATABASE
    CREATE TABLE email_list(
             first_name varchar(30),
             last_name varchar(30),
             email varchar(50)
    )
We need to define our data
     When you create a table, you have to tell the MySQL server what
     type of data each column will hold.

     To create a table, you need to know what type of data is stored in
     each table column.
Php 2
INSERT

    INSERT INTO student
    VALUES (“Trung”,”Dung”,”tdung@gmail.com”)

    INSERT INTO student (first_name,last_name,email)
    VALUES (“Trung”,”Dung”,”tdung@gmail.com”)
SELECT

    SELECT *
    FROM student

    SELECT first_name, last_name
    FROM student
WHERE Clause
    SELECT *
    FROM student
    WHERE first_name = “Dung”
UPDATE

    UPDATE student
    SET first_name = "Long"
    WHERE last_name = "Dung"
DELETE

    DELETE FROM student
    WHERE last_name = "Dung"
ORDER BY

    SELECT * FROM student
    ORDER BY last_name ASC

    SELECT * FROM student
    ORDER BY last_name DESC
Use PHP functions to talk to the database
     Connect to a database with the mysqli_connect() function.
Use PHP functions to talk to the database
     Connect to a database with the mysqli_connect() function.

             The location of the database
             (a domain name, an IPaddress or localhost)

             The name of your database

             Your username and password



        $con = mysqli_connect("localhost","root","","php")
Use PHP functions to talk to the database
     Create an SQL query and store it as a string in a PHP variable.
Use PHP functions to talk to the database
     Create an SQL query and store it as a string in a PHP variable.




        $query = "SELECT * FROM student";
Use PHP functions to talk to the database
     Issue the query with the mysqli_query() function.
Use PHP functions to talk to the database
     Issue the query with the mysqli_query() function.




        $result = mysqli_query($con, $query);
        while($row = mysqli_fetch_array($result))
                 {
                         echo $row['first_name'] . " " . $row['last_name'];
                         echo "<br />";
                 }
Php 2
Use PHP functions to talk to the database
     Close the database connection with the mysqli_close() function.
Use PHP functions to talk to the database
     Close the database connection with the mysqli_close() function.




        mysqli_close($con);

More Related Content

What's hot (19)

PDF
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
PDF
Python Files
Vikram Nandini
 
PPTX
PostgreSQL's Secret NoSQL Superpowers
Amanda Gilmore
 
PDF
SXML: S-expression eXtensible Markup Language
elliando dias
 
PPTX
MS SQL Database basic
wali1195189
 
PDF
Groovy as a scripting language
Jenn Strater
 
PPT
Php Mysql
Mudasir Syed
 
PPTX
GraphQL API for Frontend Devs
Chris Nwamba
 
PPTX
Xpath & xquery
Meghavi patel
 
PPTX
XML and Web Services
Henry Osborne
 
KEY
Introducing CakeEntity
Basuke Suzuki
 
KEY
Introducing CakeEntity
Basuke Suzuki
 
DOCX
Php update and delet operation
syeda zoya mehdi
 
PDF
Moose Lightning Talk
Mike Whitaker
 
PPTX
PHP Lecture 6 - Php file uploading
Al-Mamun Sarkar
 
PPTX
13. CodeIgniter vederea inregistrarilor3
Razvan Raducanu, PhD
 
PDF
Scaling Databases with DBIx::Router
Perrin Harkins
 
PPTX
Database Management - Lecture 4 - PHP and Mysql
Al-Mamun Sarkar
 
PPTX
PHP Lecture 4 - Working with form, GET and Post Methods
Al-Mamun Sarkar
 
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
Python Files
Vikram Nandini
 
PostgreSQL's Secret NoSQL Superpowers
Amanda Gilmore
 
SXML: S-expression eXtensible Markup Language
elliando dias
 
MS SQL Database basic
wali1195189
 
Groovy as a scripting language
Jenn Strater
 
Php Mysql
Mudasir Syed
 
GraphQL API for Frontend Devs
Chris Nwamba
 
Xpath & xquery
Meghavi patel
 
XML and Web Services
Henry Osborne
 
Introducing CakeEntity
Basuke Suzuki
 
Introducing CakeEntity
Basuke Suzuki
 
Php update and delet operation
syeda zoya mehdi
 
Moose Lightning Talk
Mike Whitaker
 
PHP Lecture 6 - Php file uploading
Al-Mamun Sarkar
 
13. CodeIgniter vederea inregistrarilor3
Razvan Raducanu, PhD
 
Scaling Databases with DBIx::Router
Perrin Harkins
 
Database Management - Lecture 4 - PHP and Mysql
Al-Mamun Sarkar
 
PHP Lecture 4 - Working with form, GET and Post Methods
Al-Mamun Sarkar
 

Similar to Php 2 (20)

PPTX
UNIT V (5).pptx
DrDhivyaaCRAssistant
 
PPTX
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
PPTX
CHAPTER six DataBase Driven Websites.pptx
KelemAlebachew
 
PPTX
PHP DATABASE MANAGEMENT.pptx
CynthiaKendi1
 
ODP
Php modul-3
Kristophorus Hadiono
 
PPSX
DIWE - Working with MySQL Databases
Rasan Samarasinghe
 
PPTX
This slide show will brief about database handling
averynight005
 
PPTX
Connecting_to_Database(MySQL)_in_PHP.pptx
TempMail233488
 
PPTX
MySQL with PHP
MsSJeyalakshmiVelsUn
 
DOC
Ex[1].3 php db connectivity
Mouli Chandira
 
PDF
4.3 MySQL + PHP
Jalpesh Vasa
 
PPT
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
PPT
Lecture 15 - MySQL- PHP 1.ppt
TempMail233488
 
PPT
qwe.ppt
Heru762601
 
PPT
Geek Austin PHP Class - Session 4
jimbojsb
 
PPTX
3 php-connect-to-my sql
Achchuthan Yogarajah
 
PPTX
3-Chapter-Edit.pptx debre tabour university
alemunuruhak9
 
PPTX
Chapter 3.1.pptx
mebratu9
 
UNIT V (5).pptx
DrDhivyaaCRAssistant
 
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
CHAPTER six DataBase Driven Websites.pptx
KelemAlebachew
 
PHP DATABASE MANAGEMENT.pptx
CynthiaKendi1
 
DIWE - Working with MySQL Databases
Rasan Samarasinghe
 
This slide show will brief about database handling
averynight005
 
Connecting_to_Database(MySQL)_in_PHP.pptx
TempMail233488
 
MySQL with PHP
MsSJeyalakshmiVelsUn
 
Ex[1].3 php db connectivity
Mouli Chandira
 
4.3 MySQL + PHP
Jalpesh Vasa
 
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
Lecture 15 - MySQL- PHP 1.ppt
TempMail233488
 
qwe.ppt
Heru762601
 
Geek Austin PHP Class - Session 4
jimbojsb
 
3 php-connect-to-my sql
Achchuthan Yogarajah
 
3-Chapter-Edit.pptx debre tabour university
alemunuruhak9
 
Chapter 3.1.pptx
mebratu9
 
Ad

Recently uploaded (20)

PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Python basic programing language for automation
DanialHabibi2
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Ad

Php 2

  • 3. A database is an organized collection of data for one or more purposes.
  • 4. Where’s database data actually stored? Can I see the files? Database data is typically stored in files on a hard disk although you could certainly look at them.
  • 6. Relational Database use tables to store information Tables store data in a grid-like pattern of columns and rows.
  • 9. SQL is the query language used to communicate with a MySQL database.
  • 10. Tool to manage MySQL
  • 11. SQL can be divided into two parts Data Manipulation Language (DML) SELECT UPDATE DELETE INSERT INTO Data Definition Language (DDL) CREATE DATABASE ALTER DATABASE CREATE TABLE ALTER TABLE DROP TABLE CREATE INDEX DROP INDEX
  • 12. CREATE DATABASE CREATE DATABASE elvis_store
  • 14. CREATE TABLE INSIDE THE DATABASE CREATE TABLE email_list( first_name varchar(30), last_name varchar(30), email varchar(50) )
  • 15. We need to define our data When you create a table, you have to tell the MySQL server what type of data each column will hold. To create a table, you need to know what type of data is stored in each table column.
  • 17. INSERT INSERT INTO student VALUES (“Trung”,”Dung”,”[email protected]”) INSERT INTO student (first_name,last_name,email) VALUES (“Trung”,”Dung”,”[email protected]”)
  • 18. SELECT SELECT * FROM student SELECT first_name, last_name FROM student
  • 19. WHERE Clause SELECT * FROM student WHERE first_name = “Dung”
  • 20. UPDATE UPDATE student SET first_name = "Long" WHERE last_name = "Dung"
  • 21. DELETE DELETE FROM student WHERE last_name = "Dung"
  • 22. ORDER BY SELECT * FROM student ORDER BY last_name ASC SELECT * FROM student ORDER BY last_name DESC
  • 23. Use PHP functions to talk to the database Connect to a database with the mysqli_connect() function.
  • 24. Use PHP functions to talk to the database Connect to a database with the mysqli_connect() function. The location of the database (a domain name, an IPaddress or localhost) The name of your database Your username and password $con = mysqli_connect("localhost","root","","php")
  • 25. Use PHP functions to talk to the database Create an SQL query and store it as a string in a PHP variable.
  • 26. Use PHP functions to talk to the database Create an SQL query and store it as a string in a PHP variable. $query = "SELECT * FROM student";
  • 27. Use PHP functions to talk to the database Issue the query with the mysqli_query() function.
  • 28. Use PHP functions to talk to the database Issue the query with the mysqli_query() function. $result = mysqli_query($con, $query); while($row = mysqli_fetch_array($result)) { echo $row['first_name'] . " " . $row['last_name']; echo "<br />"; }
  • 30. Use PHP functions to talk to the database Close the database connection with the mysqli_close() function.
  • 31. Use PHP functions to talk to the database Close the database connection with the mysqli_close() function. mysqli_close($con);