SlideShare una empresa de Scribd logo
1 de 9
By
Ishaq khan Shinwari
How to create database
using phpmyadmin



 Goto : http://localhost/phpmyadmin in browser
 In Create New Database field: put the name of your
Database (ie: my_db)
 Click on Go button
Now your database is ready and you can create
tables
How to create table using
phpmyadmin



 Click on your database name
 Put the name of table in table field
 Put the number of fields in your database
 Click on go
 Now you can put the length, type etc to each feild
How to connect php file
with database



 Before you can access data in a database, you must
create a connection to the database.
 In PHP, this is done with the mysql_connect()
function.
 Syntax:
 mysql_connect(servername,username,password);
Example

 <?php $con = mysql_connect("localhost",“root","");
 if (!$con)
{
 die('Could not connect: ' . mysql_error());
 }
 Else echo” your are connect with database”;
 mysql_close($con);
 ?>
Insert Data into tables


<?php
$con = mysql_connect("localhost",“root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
mysql_query("INSERT INTO Persons (FirstName, LastName,
Age) VALUES ('Peter', 'Griffin', '35')");
 mysql_query("INSERT INTO Persons (FirstName, LastName,
Age) VALUES ('Glenn', 'Quagmire', '33')");
 mysql_close($con);
 ?>








Delete Record


<?php
$con = mysql_connect("localhost",“root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
mysql_query("DELETE FROM Person WHERE
LastName='Griffin'");
 mysql_close($con);
 ?>








Update record

<?php
$con = mysql_connect("localhost",“root",""); if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
mysql_query("UPDATE Person SET Age = '36' WHERE
FirstName = 'Peter' AND LastName = 'Griffin'");
 mysql_close($con);
 ?>






















Select Data from
Database


<?php
$con = mysql_connect("localhost","peter","abc123"); if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM Persons");
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br />";
}
mysql_close($con);
?>

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Php cookies
Php cookiesPhp cookies
Php cookies
 
Lecture8 php page control by okello erick
Lecture8 php page control by okello erickLecture8 php page control by okello erick
Lecture8 php page control by okello erick
 
Uploading a file with php
Uploading a file with phpUploading a file with php
Uploading a file with php
 
php $_GET / $_POST / $_SESSION
php  $_GET / $_POST / $_SESSIONphp  $_GET / $_POST / $_SESSION
php $_GET / $_POST / $_SESSION
 
Php session
Php sessionPhp session
Php session
 
Introduction to php web programming - sessions and cookies
Introduction to php   web programming - sessions and cookiesIntroduction to php   web programming - sessions and cookies
Introduction to php web programming - sessions and cookies
 
Php mysql connectivity
Php mysql connectivityPhp mysql connectivity
Php mysql connectivity
 
Php session 3 Important topics
Php session 3 Important topicsPhp session 3 Important topics
Php session 3 Important topics
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Php file upload, cookies & session
Php file upload, cookies & sessionPhp file upload, cookies & session
Php file upload, cookies & session
 
Wordpress install setup
Wordpress install setupWordpress install setup
Wordpress install setup
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 
File Upload
File UploadFile Upload
File Upload
 
17 sessions
17 sessions17 sessions
17 sessions
 
4.4 PHP Session
4.4 PHP Session4.4 PHP Session
4.4 PHP Session
 
05 File Handling Upload Mysql
05 File Handling Upload Mysql05 File Handling Upload Mysql
05 File Handling Upload Mysql
 
Freeingwebhost
FreeingwebhostFreeingwebhost
Freeingwebhost
 
Php 2
Php 2Php 2
Php 2
 
Check username availability with vue.js and PHP
Check username availability with vue.js and PHPCheck username availability with vue.js and PHP
Check username availability with vue.js and PHP
 
Php with mysql ppt
Php with mysql pptPhp with mysql ppt
Php with mysql ppt
 

Destacado

Css, CaseCading Style Sheet
Css, CaseCading Style SheetCss, CaseCading Style Sheet
Css, CaseCading Style SheetIshaq Shinwari
 
Web security chapter#2
Web security chapter#2Web security chapter#2
Web security chapter#2Ishaq Shinwari
 
Slider yessika power point
Slider yessika power pointSlider yessika power point
Slider yessika power pointjessikandreina
 
Hypertext_markup_language
Hypertext_markup_languageHypertext_markup_language
Hypertext_markup_languageIshaq Shinwari
 
Tim Hill 4.4 PPP Presentation
Tim Hill 4.4 PPP PresentationTim Hill 4.4 PPP Presentation
Tim Hill 4.4 PPP Presentationtimothyghill
 
John Overall at Word Camp Victoria 2011
John Overall at Word Camp Victoria 2011John Overall at Word Camp Victoria 2011
John Overall at Word Camp Victoria 2011John Overall
 
Euruko 2009 - DataObjects
Euruko 2009 - DataObjectsEuruko 2009 - DataObjects
Euruko 2009 - DataObjectsDirkjan Bussink
 
How to Install Magento 2 on XAMPP Server localhost.
How to Install Magento 2 on XAMPP Server localhost.How to Install Magento 2 on XAMPP Server localhost.
How to Install Magento 2 on XAMPP Server localhost.Web Visitors
 
WordPress Training Beginner
WordPress Training BeginnerWordPress Training Beginner
WordPress Training BeginnerJohn Overall
 
MongoDB: Repository for Web-scale metadata
MongoDB: Repository for Web-scale metadataMongoDB: Repository for Web-scale metadata
MongoDB: Repository for Web-scale metadatatkramar
 
jclouds overview
jclouds overviewjclouds overview
jclouds overviewAdrian Cole
 
St14 electrical detroit upgrade mod
St14 electrical detroit upgrade modSt14 electrical detroit upgrade mod
St14 electrical detroit upgrade modAlex cuevas
 
18 Phobias Every Creative MUST Overcome!
18 Phobias Every Creative MUST Overcome!18 Phobias Every Creative MUST Overcome!
18 Phobias Every Creative MUST Overcome!DesignMantic
 
When small problems become big problems
When small problems become big problemsWhen small problems become big problems
When small problems become big problemsAdrian Cole
 
Parker Devonne 3.4
Parker Devonne 3.4Parker Devonne 3.4
Parker Devonne 3.4Devo TKid
 

Destacado (20)

Jquery image slider
Jquery image slider Jquery image slider
Jquery image slider
 
Jquery part-II
Jquery part-IIJquery part-II
Jquery part-II
 
Css, CaseCading Style Sheet
Css, CaseCading Style SheetCss, CaseCading Style Sheet
Css, CaseCading Style Sheet
 
Web security chapter#2
Web security chapter#2Web security chapter#2
Web security chapter#2
 
Slider yessika power point
Slider yessika power pointSlider yessika power point
Slider yessika power point
 
Hypertext_markup_language
Hypertext_markup_languageHypertext_markup_language
Hypertext_markup_language
 
Tim Hill 4.4 PPP Presentation
Tim Hill 4.4 PPP PresentationTim Hill 4.4 PPP Presentation
Tim Hill 4.4 PPP Presentation
 
John Overall at Word Camp Victoria 2011
John Overall at Word Camp Victoria 2011John Overall at Word Camp Victoria 2011
John Overall at Word Camp Victoria 2011
 
Euruko 2009 - DataObjects
Euruko 2009 - DataObjectsEuruko 2009 - DataObjects
Euruko 2009 - DataObjects
 
56 alumbrado
56 alumbrado56 alumbrado
56 alumbrado
 
How to Install Magento 2 on XAMPP Server localhost.
How to Install Magento 2 on XAMPP Server localhost.How to Install Magento 2 on XAMPP Server localhost.
How to Install Magento 2 on XAMPP Server localhost.
 
WordPress Training Beginner
WordPress Training BeginnerWordPress Training Beginner
WordPress Training Beginner
 
MongoDB: Repository for Web-scale metadata
MongoDB: Repository for Web-scale metadataMongoDB: Repository for Web-scale metadata
MongoDB: Repository for Web-scale metadata
 
jclouds overview
jclouds overviewjclouds overview
jclouds overview
 
St14 electrical detroit upgrade mod
St14 electrical detroit upgrade modSt14 electrical detroit upgrade mod
St14 electrical detroit upgrade mod
 
Instant Rails
Instant RailsInstant Rails
Instant Rails
 
L 150 e-_sensor
L 150 e-_sensorL 150 e-_sensor
L 150 e-_sensor
 
18 Phobias Every Creative MUST Overcome!
18 Phobias Every Creative MUST Overcome!18 Phobias Every Creative MUST Overcome!
18 Phobias Every Creative MUST Overcome!
 
When small problems become big problems
When small problems become big problemsWhen small problems become big problems
When small problems become big problems
 
Parker Devonne 3.4
Parker Devonne 3.4Parker Devonne 3.4
Parker Devonne 3.4
 

Similar a My_sql_with_php

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
 
Intro to php
Intro to phpIntro to php
Intro to phpSp Singh
 
Chapter 3.1.pptx
Chapter 3.1.pptxChapter 3.1.pptx
Chapter 3.1.pptxmebratu9
 
RequirementsAddToMailList.txt ;echo Thank you for Jo.docx
RequirementsAddToMailList.txt   ;echo Thank you for Jo.docxRequirementsAddToMailList.txt   ;echo Thank you for Jo.docx
RequirementsAddToMailList.txt ;echo Thank you for Jo.docxsodhi3
 
Database presentation
Database presentationDatabase presentation
Database presentationwebhostingguy
 
Rits Brown Bag - PHP & PHPMyAdmin
Rits Brown Bag - PHP & PHPMyAdminRits Brown Bag - PHP & PHPMyAdmin
Rits Brown Bag - PHP & PHPMyAdminRight IT Services
 
Connecting_to_Database(MySQL)_in_PHP.pptx
Connecting_to_Database(MySQL)_in_PHP.pptxConnecting_to_Database(MySQL)_in_PHP.pptx
Connecting_to_Database(MySQL)_in_PHP.pptxTempMail233488
 
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
 
PHP and Databases
PHP and DatabasesPHP and Databases
PHP and DatabasesThings Lab
 
Quick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHPQuick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHPSanju Sony Kurian
 
How to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdfHow to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdfAppweb Coders
 
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
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kianphelios
 
PHP DATABASE MANAGEMENT.pptx
PHP DATABASE MANAGEMENT.pptxPHP DATABASE MANAGEMENT.pptx
PHP DATABASE MANAGEMENT.pptxCynthiaKendi1
 

Similar a My_sql_with_php (20)

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
 
Intro to php
Intro to phpIntro to php
Intro to php
 
Chapter 3.1.pptx
Chapter 3.1.pptxChapter 3.1.pptx
Chapter 3.1.pptx
 
lab56_db
lab56_dblab56_db
lab56_db
 
lab56_db
lab56_dblab56_db
lab56_db
 
RequirementsAddToMailList.txt ;echo Thank you for Jo.docx
RequirementsAddToMailList.txt   ;echo Thank you for Jo.docxRequirementsAddToMailList.txt   ;echo Thank you for Jo.docx
RequirementsAddToMailList.txt ;echo Thank you for Jo.docx
 
Php talk
Php talkPhp talk
Php talk
 
Database presentation
Database presentationDatabase presentation
Database presentation
 
Rits Brown Bag - PHP & PHPMyAdmin
Rits Brown Bag - PHP & PHPMyAdminRits Brown Bag - PHP & PHPMyAdmin
Rits Brown Bag - PHP & PHPMyAdmin
 
Connecting_to_Database(MySQL)_in_PHP.pptx
Connecting_to_Database(MySQL)_in_PHP.pptxConnecting_to_Database(MySQL)_in_PHP.pptx
Connecting_to_Database(MySQL)_in_PHP.pptx
 
Php
PhpPhp
Php
 
Php basics
Php basicsPhp basics
Php basics
 
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
 
PHP and Databases
PHP and DatabasesPHP and Databases
PHP and Databases
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
 
Quick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHPQuick beginner to Lower-Advanced guide/tutorial in PHP
Quick beginner to Lower-Advanced guide/tutorial in PHP
 
How to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdfHow to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdf
 
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
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
 
PHP DATABASE MANAGEMENT.pptx
PHP DATABASE MANAGEMENT.pptxPHP DATABASE MANAGEMENT.pptx
PHP DATABASE MANAGEMENT.pptx
 

Último

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Último (20)

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 

My_sql_with_php

  • 2. How to create database using phpmyadmin   Goto : http://localhost/phpmyadmin in browser  In Create New Database field: put the name of your Database (ie: my_db)  Click on Go button Now your database is ready and you can create tables
  • 3. How to create table using phpmyadmin   Click on your database name  Put the name of table in table field  Put the number of fields in your database  Click on go  Now you can put the length, type etc to each feild
  • 4. How to connect php file with database   Before you can access data in a database, you must create a connection to the database.  In PHP, this is done with the mysql_connect() function.  Syntax:  mysql_connect(servername,username,password);
  • 5. Example   <?php $con = mysql_connect("localhost",“root","");  if (!$con) {  die('Could not connect: ' . mysql_error());  }  Else echo” your are connect with database”;  mysql_close($con);  ?>
  • 6. Insert Data into tables  <?php $con = mysql_connect("localhost",“root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_query("INSERT INTO Persons (FirstName, LastName, Age) VALUES ('Peter', 'Griffin', '35')");  mysql_query("INSERT INTO Persons (FirstName, LastName, Age) VALUES ('Glenn', 'Quagmire', '33')");  mysql_close($con);  ?>        
  • 7. Delete Record  <?php $con = mysql_connect("localhost",“root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_query("DELETE FROM Person WHERE LastName='Griffin'");  mysql_close($con);  ?>        
  • 8. Update record  <?php $con = mysql_connect("localhost",“root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_query("UPDATE Person SET Age = '36' WHERE FirstName = 'Peter' AND LastName = 'Griffin'");  mysql_close($con);  ?>       
  • 9.               Select Data from Database  <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM Persons"); while($row = mysql_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName']; echo "<br />"; } mysql_close($con); ?>