SlideShare a Scribd company logo
WELCOME
INTRODUCTION TO
PHP-MySQL CONNECTIVITY
What you Benefit ???
By the end of this session you will learn how to use PHP to
● Store the data into database.
● Retrieve data from the backend database in real-time.
TASK OF THE DAY
Create the registration form shown here and store the data passed with it into a
database .
INTRODUCTION TO PHP DATABASE
CONNECTIVITY
Introduction To PHP Database
Connectivity
We had already tried passing data to a server .
But..where do we store this data and how…?
How To Connect PHP to Database?
Step 1 : Connecting to MySQL Server
Step 2 : Selecting Database
Step 3 : Query Execution
STEP 1 -
CONNECTING TO MySQL SERVER
mysql_connect(‘host_name’,’username’,’password’);
Eg: mysql_connect(‘localhost’,’root’,’root’);
STEP 2-
SELECTING DATABASE
mysql_select_db(‘Database Name’);
Eg: mysql_select_db(‘baabtra_db’);
STEP 3-
QUERY EXECUTION
mysql_query(“query to be executed”);
Eg: mysql_query(“update table baabtra_mentees_tbl
set vchr_cmpny_name=’Baabtra’
where pk_int_branch_id=’Caffit’ ”);
Let’s TRY
Why don’t we make it even more interesting by implementing this with our task.
So let’s start
TASK
Step1: Create the Registration form
STEP 1
Registration.html
Step2
Step 2: Now create a database to store the data passed from registration form
Step 2
Lets create the database
create database company_baabtra;
Create a table tbl_baabtra_mentees as shown here
Step 3
Step 3: Retrieve the data passed using POST method from register_action.php
Checks if button click is set
File upload
Reading the
checked values from
checkbox
Step 4
Step 4: Data is now available at register_action.php. So next step is to store this
data into the database.
Step 4
register_action.php
Connects to remote server
Step 4
register_action.php
Selects the database
Step 4
register_action.php Executes the mysql query to
store the registered mentee
information into database
Step 5
Step 5: Run your registration form from the localhost now
Step 5
Step 6
Step 6: Check your database. It should be updated somewhat like that
Connecting Database to PHP
Now how do we fetch the data stored in database from frontend ??
Retrieving Data From MySQL
There are four different ways to fetch the data from database using PHP.
▪ Mysql_fetch_array()
▪ Mysql_fetch_row()
▪ Mysql_fetch_assoc()
▪ Mysql_fetch_object()
All of the above will return one row from table at a time and then the next row
and so on . So usually we use these functions along with a while loop
mysql_fetch_row()
$query = mysql_query (“select * from tbl_baabtra_mentees");
while($fetch=mysql_fetch_row($query))
{
echo $fetch[0]; //prints first column the retrieved row
echo $fetch[1]; //prints second column the retrieved row
}
mysql_fetch_assoc()
$query = mysql_query (“select * from tbl_baabtra_mentees");
while($fetch=mysql_fetch_assoc($query))
{
echo $fetch[‘vchr_uname’]; //prints first column the retrieved row
echo $fetch[‘vchr_phone’]; //prints second column the retrieved row
}
mysql_fetch_array()
$query = mysql_query (“select * from tbl_baabtra_mentees");
while($fetch=mysql_fetch_array($query))
{
echo $fetch[0]; //prints first column the retrieved row
echo $fetch[‘vchr_phone’]; //prints second column the retrieved row
}
mysql_fetch_object()
$query = mysql_query (“select * from tbl_baabtra_mentees");
while($fetch=mysql_fetch_object($query))
{
echo $fetch -> ‘vchr_uname’; //prints first column the retrieved row
echo $fetch -> ‘vchr_phone’; //prints second column the retrieved row
}
mysql_fetch_object()
$query = mysql_query (“select * from tbl_baabtra_mentees");
while($fetch=mysql_fetch_object($query))
{
echo $fetch -> ‘vchr_uname’; //prints first column the retrieved row
echo $fetch -> ‘vchr_phone’; //prints second column the retrieved row
}
“Returns an object with properties that correspond to the fetched row and moves
the internal data pointer ahead.”
Okay…!!
So what are we waiting for now..??
Lets do it then
Let’s Get Back With Our Task
Step 7: Set a header to redirect from
‘register_action.php’ to ‘view_baabtra_mentees.php’
header(‘Location: view_baabtra_mentees.php’);
Let’s Get Back With Our Task
Step 8: Now fetch the data from tbl_baabtra_mentees and display it in a
table format.
Step 8
uses mysql_fetch_row function.
returns each row of data from the
mysql table
Step 8
fetches using the column
number
Step 9
Step 9: Run the registration form from localhost now
Step 9
On Submit it displays the list of mentees registered
Woooh….!!! That really works…
So we are done with our TASK of the day.
That was great…!!!
END OF THE SESSION

More Related Content

What's hot

Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
Maruf Abdullah (Rion)
 
Php array
Php arrayPhp array
Php array
Nikul Shah
 
PHP
PHPPHP
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
CPD INDIA
 
Files in java
Files in javaFiles in java
Php string function
Php string function Php string function
Php string function
Ravi Bhadauria
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
Vibrant Technologies & Computers
 
Php forms
Php formsPhp forms
Php forms
Anne Lee
 
Basics PHP
Basics PHPBasics PHP
Interface
InterfaceInterface
Interface
kamal kotecha
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
Php
PhpPhp
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
Mindfire Solutions
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
Vineet Kumar Saini
 

What's hot (20)

Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
 
Php array
Php arrayPhp array
Php array
 
PHP
PHPPHP
PHP
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
PHP slides
PHP slidesPHP slides
PHP slides
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
Files in java
Files in javaFiles in java
Files in java
 
Php string function
Php string function Php string function
Php string function
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
 
Php forms
Php formsPhp forms
Php forms
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Interface
InterfaceInterface
Interface
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php
PhpPhp
Php
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 

Viewers also liked

Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With MysqlHarit Kothari
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
Tiji Thomas
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Session 2 django material for training at baabtra models
Session 2 django material for training at baabtra modelsSession 2 django material for training at baabtra models
Session 2 django material for training at baabtra models
baabtra.com - No. 1 supplier of quality freshers
 
templates in Django material : Training available at Baabtra
templates in Django material : Training available at Baabtratemplates in Django material : Training available at Baabtra
templates in Django material : Training available at Baabtra
baabtra.com - No. 1 supplier of quality freshers
 
Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introduction
Programmer Blog
 
PHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and SessionsPHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and Sessions
Vibrant Technologies & Computers
 
PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
Nisa Soomro
 
Database presentation
Database presentationDatabase presentation
Database presentationwebhostingguy
 
PHP MYSQL And IIS2.ppt
PHP MYSQL And IIS2.pptPHP MYSQL And IIS2.ppt
PHP MYSQL And IIS2.pptwebhostingguy
 
Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
www.netgains.org
 
Cookie and session
Cookie and sessionCookie and session
Cookie and session
Aashish Ghale
 
Php MySql For Beginners
Php MySql For BeginnersPhp MySql For Beginners
Php MySql For Beginners
Priti Solanki
 
PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
Pankil Agrawal
 
Cookies PowerPoint
Cookies PowerPointCookies PowerPoint
Cookies PowerPointemurfield
 

Viewers also liked (20)

Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With Mysql
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Session 2 django material for training at baabtra models
Session 2 django material for training at baabtra modelsSession 2 django material for training at baabtra models
Session 2 django material for training at baabtra models
 
templates in Django material : Training available at Baabtra
templates in Django material : Training available at Baabtratemplates in Django material : Training available at Baabtra
templates in Django material : Training available at Baabtra
 
Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introduction
 
PHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and SessionsPHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and Sessions
 
PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
 
Database presentation
Database presentationDatabase presentation
Database presentation
 
PHP MYSQL And IIS2.ppt
PHP MYSQL And IIS2.pptPHP MYSQL And IIS2.ppt
PHP MYSQL And IIS2.ppt
 
Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
 
Cookie and session
Cookie and sessionCookie and session
Cookie and session
 
Php Ppt
Php PptPhp Ppt
Php Ppt
 
Php MySql For Beginners
Php MySql For BeginnersPhp MySql For Beginners
Php MySql For Beginners
 
PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
 
Cookies PowerPoint
Cookies PowerPointCookies PowerPoint
Cookies PowerPoint
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 

Similar to Php database connectivity

Using php with my sql
Using php with my sqlUsing php with my sql
Using php with my sqlsalissal
 
Learn PHP Lacture2
Learn PHP Lacture2Learn PHP Lacture2
Learn PHP Lacture2ADARSH BHATT
 
Php and MySQL Web Development
Php and MySQL Web DevelopmentPhp and MySQL Web Development
Php and MySQL Web Development
w3ondemand
 
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHPDifference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
Vineet Kumar Saini
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
Mudasir Syed
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
Ivano Malavolta
 
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
 
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering CollegeDatabase Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
UNIT V (5).pptx
UNIT V (5).pptxUNIT V (5).pptx
UNIT V (5).pptx
DrDhivyaaCRAssistant
 
Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...
Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...
Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...
DicodingEvent
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
Nate Abele
 
PythonDatabaseAPI -Presentation for Database
PythonDatabaseAPI -Presentation for DatabasePythonDatabaseAPI -Presentation for Database
PythonDatabaseAPI -Presentation for Database
dharawagh9999
 
Php basics
Php basicsPhp basics
Php basics
Egerton University
 
Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09
Michelangelo van Dam
 
ZendCon2010 The Doctrine Project
ZendCon2010 The Doctrine ProjectZendCon2010 The Doctrine Project
ZendCon2010 The Doctrine ProjectJonathan Wage
 
Power shell examples_v4
Power shell examples_v4Power shell examples_v4
Power shell examples_v4
JoeDinaso
 
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
wahidullah mudaser
 
24. SQL .pdf
24. SQL .pdf24. SQL .pdf
24. SQL .pdf
Bhavya103897
 
HeadCouch - CouchDB PHP Client
HeadCouch - CouchDB PHP ClientHeadCouch - CouchDB PHP Client
HeadCouch - CouchDB PHP Client
Dimitar Ivanov
 

Similar to Php database connectivity (20)

Introduction to php database connectivity
Introduction to php  database connectivityIntroduction to php  database connectivity
Introduction to php database connectivity
 
Using php with my sql
Using php with my sqlUsing php with my sql
Using php with my sql
 
Learn PHP Lacture2
Learn PHP Lacture2Learn PHP Lacture2
Learn PHP Lacture2
 
Php and MySQL Web Development
Php and MySQL Web DevelopmentPhp and MySQL Web Development
Php and MySQL Web Development
 
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHPDifference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 
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
 
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering CollegeDatabase Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
 
UNIT V (5).pptx
UNIT V (5).pptxUNIT V (5).pptx
UNIT V (5).pptx
 
Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...
Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...
Dicoding Developer Coaching #27: Android | Membuat Aplikasi Support Online Ma...
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
PythonDatabaseAPI -Presentation for Database
PythonDatabaseAPI -Presentation for DatabasePythonDatabaseAPI -Presentation for Database
PythonDatabaseAPI -Presentation for Database
 
Php basics
Php basicsPhp basics
Php basics
 
Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09Spl Not A Bridge Too Far phpNW09
Spl Not A Bridge Too Far phpNW09
 
ZendCon2010 The Doctrine Project
ZendCon2010 The Doctrine ProjectZendCon2010 The Doctrine Project
ZendCon2010 The Doctrine Project
 
Power shell examples_v4
Power shell examples_v4Power shell examples_v4
Power shell examples_v4
 
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
 
24. SQL .pdf
24. SQL .pdf24. SQL .pdf
24. SQL .pdf
 
HeadCouch - CouchDB PHP Client
HeadCouch - CouchDB PHP ClientHeadCouch - CouchDB PHP Client
HeadCouch - CouchDB PHP Client
 

More from baabtra.com - No. 1 supplier of quality freshers

Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Blue brain
Blue brainBlue brain
5g
5g5g
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Baabtra soft skills
Baabtra soft skillsBaabtra soft skills
Cell phone jammer
Cell phone jammerCell phone jammer
Apple iwatches
Apple iwatchesApple iwatches

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 
Baabtra soft skills
Baabtra soft skillsBaabtra soft skills
Baabtra soft skills
 
Cell phone jammer
Cell phone jammerCell phone jammer
Cell phone jammer
 
Apple iwatches
Apple iwatchesApple iwatches
Apple iwatches
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 

Php database connectivity

  • 3. What you Benefit ??? By the end of this session you will learn how to use PHP to ● Store the data into database. ● Retrieve data from the backend database in real-time.
  • 4. TASK OF THE DAY Create the registration form shown here and store the data passed with it into a database .
  • 5. INTRODUCTION TO PHP DATABASE CONNECTIVITY
  • 6. Introduction To PHP Database Connectivity We had already tried passing data to a server . But..where do we store this data and how…?
  • 7. How To Connect PHP to Database? Step 1 : Connecting to MySQL Server Step 2 : Selecting Database Step 3 : Query Execution
  • 8. STEP 1 - CONNECTING TO MySQL SERVER mysql_connect(‘host_name’,’username’,’password’); Eg: mysql_connect(‘localhost’,’root’,’root’);
  • 9. STEP 2- SELECTING DATABASE mysql_select_db(‘Database Name’); Eg: mysql_select_db(‘baabtra_db’);
  • 10. STEP 3- QUERY EXECUTION mysql_query(“query to be executed”); Eg: mysql_query(“update table baabtra_mentees_tbl set vchr_cmpny_name=’Baabtra’ where pk_int_branch_id=’Caffit’ ”);
  • 11. Let’s TRY Why don’t we make it even more interesting by implementing this with our task. So let’s start
  • 12. TASK Step1: Create the Registration form
  • 14. Step2 Step 2: Now create a database to store the data passed from registration form
  • 15. Step 2 Lets create the database create database company_baabtra; Create a table tbl_baabtra_mentees as shown here
  • 16. Step 3 Step 3: Retrieve the data passed using POST method from register_action.php Checks if button click is set File upload Reading the checked values from checkbox
  • 17. Step 4 Step 4: Data is now available at register_action.php. So next step is to store this data into the database.
  • 20. Step 4 register_action.php Executes the mysql query to store the registered mentee information into database
  • 21. Step 5 Step 5: Run your registration form from the localhost now
  • 23. Step 6 Step 6: Check your database. It should be updated somewhat like that
  • 24. Connecting Database to PHP Now how do we fetch the data stored in database from frontend ??
  • 25. Retrieving Data From MySQL There are four different ways to fetch the data from database using PHP. ▪ Mysql_fetch_array() ▪ Mysql_fetch_row() ▪ Mysql_fetch_assoc() ▪ Mysql_fetch_object() All of the above will return one row from table at a time and then the next row and so on . So usually we use these functions along with a while loop
  • 26. mysql_fetch_row() $query = mysql_query (“select * from tbl_baabtra_mentees"); while($fetch=mysql_fetch_row($query)) { echo $fetch[0]; //prints first column the retrieved row echo $fetch[1]; //prints second column the retrieved row }
  • 27. mysql_fetch_assoc() $query = mysql_query (“select * from tbl_baabtra_mentees"); while($fetch=mysql_fetch_assoc($query)) { echo $fetch[‘vchr_uname’]; //prints first column the retrieved row echo $fetch[‘vchr_phone’]; //prints second column the retrieved row }
  • 28. mysql_fetch_array() $query = mysql_query (“select * from tbl_baabtra_mentees"); while($fetch=mysql_fetch_array($query)) { echo $fetch[0]; //prints first column the retrieved row echo $fetch[‘vchr_phone’]; //prints second column the retrieved row }
  • 29. mysql_fetch_object() $query = mysql_query (“select * from tbl_baabtra_mentees"); while($fetch=mysql_fetch_object($query)) { echo $fetch -> ‘vchr_uname’; //prints first column the retrieved row echo $fetch -> ‘vchr_phone’; //prints second column the retrieved row }
  • 30. mysql_fetch_object() $query = mysql_query (“select * from tbl_baabtra_mentees"); while($fetch=mysql_fetch_object($query)) { echo $fetch -> ‘vchr_uname’; //prints first column the retrieved row echo $fetch -> ‘vchr_phone’; //prints second column the retrieved row } “Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead.”
  • 31. Okay…!! So what are we waiting for now..?? Lets do it then
  • 32. Let’s Get Back With Our Task Step 7: Set a header to redirect from ‘register_action.php’ to ‘view_baabtra_mentees.php’ header(‘Location: view_baabtra_mentees.php’);
  • 33. Let’s Get Back With Our Task Step 8: Now fetch the data from tbl_baabtra_mentees and display it in a table format.
  • 34. Step 8 uses mysql_fetch_row function. returns each row of data from the mysql table
  • 35. Step 8 fetches using the column number
  • 36. Step 9 Step 9: Run the registration form from localhost now
  • 37. Step 9 On Submit it displays the list of mentees registered
  • 38. Woooh….!!! That really works… So we are done with our TASK of the day. That was great…!!!
  • 39. END OF THE SESSION