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.
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
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.
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 />";
                 }
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

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

What's hot (19)

Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Python Files
Python FilesPython Files
Python Files
 
PostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersPostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL Superpowers
 
SXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup LanguageSXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup Language
 
MS SQL Database basic
MS SQL Database basicMS SQL Database basic
MS SQL Database basic
 
Groovy as a scripting language
Groovy as a scripting languageGroovy as a scripting language
Groovy as a scripting language
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
 
GraphQL API for Frontend Devs
GraphQL API for Frontend DevsGraphQL API for Frontend Devs
GraphQL API for Frontend Devs
 
Xpath & xquery
Xpath & xqueryXpath & xquery
Xpath & xquery
 
XML and Web Services
XML and Web ServicesXML and Web Services
XML and Web Services
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntity
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntity
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operation
 
Moose Lightning Talk
Moose Lightning TalkMoose Lightning Talk
Moose Lightning Talk
 
PHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploadingPHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploading
 
13. CodeIgniter vederea inregistrarilor3
13. CodeIgniter vederea inregistrarilor313. CodeIgniter vederea inregistrarilor3
13. CodeIgniter vederea inregistrarilor3
 
Scaling Databases with DBIx::Router
Scaling Databases with DBIx::RouterScaling Databases with DBIx::Router
Scaling Databases with DBIx::Router
 
Database Management - Lecture 4 - PHP and Mysql
Database Management - Lecture 4 - PHP and MysqlDatabase Management - Lecture 4 - PHP and Mysql
Database Management - Lecture 4 - PHP and Mysql
 
PHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post MethodsPHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post Methods
 

Similar to Php 2

PHP - Getting good with MySQL part II
 PHP - Getting good with MySQL part II PHP - Getting good with MySQL part II
PHP - Getting good with MySQL part II
Firdaus Adib
 
Chapter 3.1.pptx
Chapter 3.1.pptxChapter 3.1.pptx
Chapter 3.1.pptx
mebratu9
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
FYBSC IT Web Programming Unit V Advanced PHP and MySQL
FYBSC IT Web Programming Unit V  Advanced PHP and MySQLFYBSC IT Web Programming Unit V  Advanced PHP and MySQL
FYBSC IT Web Programming Unit V Advanced PHP and MySQL
Arti Parab Academics
 
Module 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docx
Module 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docxModule 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docx
Module 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docx
moirarandell
 
DIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesDIWE - Working with MySQL Databases
DIWE - Working with MySQL Databases
Rasan Samarasinghe
 
MySQL with PHP
MySQL with PHPMySQL with PHP
MySQL with PHP
MsSJeyalakshmiVelsUn
 
Php mysql connectivity
Php mysql connectivityPhp mysql connectivity
Php mysql connectivity
abhikwb
 
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
wahidullah mudaser
 
Using php with my sql
Using php with my sqlUsing php with my sql
Using php with my sqlsalissal
 
Synapse india reviews on php and sql
Synapse india reviews on php and sqlSynapse india reviews on php and sql
Synapse india reviews on php and sql
saritasingh19866
 
All Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for NewbiesAll Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for Newbies
Dave Stokes
 
Database Programming
Database ProgrammingDatabase Programming
Database Programming
Henry Osborne
 
Php verses MySQL
Php verses MySQLPhp verses MySQL
Php verses MySQL
CBitss Technologies
 
4.3 MySQL + PHP
4.3 MySQL + PHP4.3 MySQL + PHP
4.3 MySQL + PHP
Jalpesh Vasa
 
Lecture6 display data by okello erick
Lecture6 display data by okello erickLecture6 display data by okello erick
Lecture6 display data by okello erick
okelloerick
 
Php mysq
Php mysqPhp mysq
Php mysq
prasanna pabba
 

Similar to Php 2 (20)

PHP - Getting good with MySQL part II
 PHP - Getting good with MySQL part II PHP - Getting good with MySQL part II
PHP - Getting good with MySQL part II
 
Chapter 3.1.pptx
Chapter 3.1.pptxChapter 3.1.pptx
Chapter 3.1.pptx
 
PHP and Mysql
PHP and MysqlPHP and Mysql
PHP and Mysql
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
 
FYBSC IT Web Programming Unit V Advanced PHP and MySQL
FYBSC IT Web Programming Unit V  Advanced PHP and MySQLFYBSC IT Web Programming Unit V  Advanced PHP and MySQL
FYBSC IT Web Programming Unit V Advanced PHP and MySQL
 
Sql
SqlSql
Sql
 
Module 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docx
Module 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docxModule 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docx
Module 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docx
 
DIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesDIWE - Working with MySQL Databases
DIWE - Working with MySQL Databases
 
MySQL with PHP
MySQL with PHPMySQL with PHP
MySQL with PHP
 
Php mysql connectivity
Php mysql connectivityPhp mysql connectivity
Php mysql connectivity
 
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
 
Using php with my sql
Using php with my sqlUsing php with my sql
Using php with my sql
 
Synapse india reviews on php and sql
Synapse india reviews on php and sqlSynapse india reviews on php and sql
Synapse india reviews on php and sql
 
Php summary
Php summaryPhp summary
Php summary
 
All Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for NewbiesAll Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for Newbies
 
Database Programming
Database ProgrammingDatabase Programming
Database Programming
 
Php verses MySQL
Php verses MySQLPhp verses MySQL
Php verses MySQL
 
4.3 MySQL + PHP
4.3 MySQL + PHP4.3 MySQL + PHP
4.3 MySQL + PHP
 
Lecture6 display data by okello erick
Lecture6 display data by okello erickLecture6 display data by okello erick
Lecture6 display data by okello erick
 
Php mysq
Php mysqPhp mysq
Php mysq
 

Recently uploaded

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 

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.
  • 7.
  • 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
  • 13.
  • 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.
  • 16.
  • 17. INSERT INSERT INTO student VALUES (“Trung”,”Dung”,”tdung@gmail.com”) INSERT INTO student (first_name,last_name,email) VALUES (“Trung”,”Dung”,”tdung@gmail.com”)
  • 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 />"; }
  • 29.
  • 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);