SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
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);

Weitere ähnliche Inhalte

Was ist angesagt?

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 MongoDBMongoDB
 
PostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersPostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersAmanda 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 basicwali1195189
 
Groovy as a scripting language
Groovy as a scripting languageGroovy as a scripting language
Groovy as a scripting languageJenn Strater
 
GraphQL API for Frontend Devs
GraphQL API for Frontend DevsGraphQL API for Frontend Devs
GraphQL API for Frontend DevsChris Nwamba
 
XML and Web Services
XML and Web ServicesXML and Web Services
XML and Web ServicesHenry Osborne
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntityBasuke Suzuki
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntityBasuke Suzuki
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operationsyeda zoya mehdi
 
Moose Lightning Talk
Moose Lightning TalkMoose Lightning Talk
Moose Lightning TalkMike Whitaker
 
PHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploadingPHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploadingAl-Mamun Sarkar
 
13. CodeIgniter vederea inregistrarilor3
13. CodeIgniter vederea inregistrarilor313. CodeIgniter vederea inregistrarilor3
13. CodeIgniter vederea inregistrarilor3Razvan Raducanu, PhD
 
Scaling Databases with DBIx::Router
Scaling Databases with DBIx::RouterScaling Databases with DBIx::Router
Scaling Databases with DBIx::RouterPerrin 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 MysqlAl-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 MethodsAl-Mamun Sarkar
 

Was ist angesagt? (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
 

Ähnlich wie 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 IIFirdaus Adib
 
Chapter 3.1.pptx
Chapter 3.1.pptxChapter 3.1.pptx
Chapter 3.1.pptxmebratu9
 
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 MySQLArti 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.docxmoirarandell
 
DIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesDIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesRasan Samarasinghe
 
Php mysql connectivity
Php mysql connectivityPhp mysql connectivity
Php mysql connectivityabhikwb
 
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 sqlsaritasingh19866
 
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 NewbiesDave Stokes
 
Database Programming
Database ProgrammingDatabase Programming
Database ProgrammingHenry Osborne
 
Lecture6 display data by okello erick
Lecture6 display data by okello erickLecture6 display data by okello erick
Lecture6 display data by okello erickokelloerick
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Kürzlich hochgeladen (20)

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

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);