SlideShare a Scribd company logo
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);
?>

More Related Content

PPT
PPTX
Image upload in php MySql
PDF
RSS Application Using Dom
ODP
Php File Upload
PDF
Php workshop L04 database
PDF
Php workshop L03 superglobals
PDF
Web app development_cookies_sessions_14
PPTX
Php sessions
Image upload in php MySql
RSS Application Using Dom
Php File Upload
Php workshop L04 database
Php workshop L03 superglobals
Web app development_cookies_sessions_14
Php sessions

What's hot (20)

PPTX
Php cookies
PPT
Lecture8 php page control by okello erick
PPTX
Uploading a file with php
PPT
php $_GET / $_POST / $_SESSION
PPSX
Php session
PDF
Introduction to php web programming - sessions and cookies
DOCX
Php mysql connectivity
PPTX
Php session 3 Important topics
PPTX
Php file upload, cookies & session
PPT
Wordpress install setup
PPT
Cookies and sessions
PPT
File Upload
PPT
17 sessions
PDF
4.4 PHP Session
PPT
05 File Handling Upload Mysql
DOCX
Freeingwebhost
PDF
Php 2
PDF
Check username availability with vue.js and PHP
PPTX
Php with mysql ppt
Php cookies
Lecture8 php page control by okello erick
Uploading a file with php
php $_GET / $_POST / $_SESSION
Php session
Introduction to php web programming - sessions and cookies
Php mysql connectivity
Php session 3 Important topics
Php file upload, cookies & session
Wordpress install setup
Cookies and sessions
File Upload
17 sessions
4.4 PHP Session
05 File Handling Upload Mysql
Freeingwebhost
Php 2
Check username availability with vue.js and PHP
Php with mysql ppt
Ad

Viewers also liked (20)

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

Similar to My_sql_with_php (20)

PPTX
Web Application Development using PHP Chapter 6
PPTX
PHP DATABASE MANAGEMENT.pptx
PPT
Chapter 09 php my sql
PPTX
MySQL with PHP
PPTX
FYBSC IT Web Programming Unit V Advanced PHP and MySQL
PPTX
chapter_Seven Database manipulation using php.pptx
PPTX
Chapter 3.1.pptx
PPTX
Mysqldatabaseandphpmyadmin sujit bera
PPTX
3-Chapter-Edit.pptx debre tabour university
PPTX
Connecting to my sql using PHP
PPTX
Learn PHP Lacture2
PPTX
Connecting_to_Database(MySQL)_in_PHP.pptx
ODP
PPTX
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
PPTX
UNIT V (5).pptx
PDF
4.3 MySQL + PHP
DOCX
Module 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docx
PPTX
CHAPTER six DataBase Driven Websites.pptx
PPTX
MySQL Database with phpMyAdmin
PPTX
Php mysq
Web Application Development using PHP Chapter 6
PHP DATABASE MANAGEMENT.pptx
Chapter 09 php my sql
MySQL with PHP
FYBSC IT Web Programming Unit V Advanced PHP and MySQL
chapter_Seven Database manipulation using php.pptx
Chapter 3.1.pptx
Mysqldatabaseandphpmyadmin sujit bera
3-Chapter-Edit.pptx debre tabour university
Connecting to my sql using PHP
Learn PHP Lacture2
Connecting_to_Database(MySQL)_in_PHP.pptx
Database Connectivity MYSQL by Dr.C.R.Dhivyaa Kongu Engineering College
UNIT V (5).pptx
4.3 MySQL + PHP
Module 6WEB SERVER AND SERVER SIDE SCRPTING, PART-2Chapte.docx
CHAPTER six DataBase Driven Websites.pptx
MySQL Database with phpMyAdmin
Php mysq

Recently uploaded (20)

PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Cell Structure & Organelles in detailed.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Institutional Correction lecture only . . .
Supply Chain Operations Speaking Notes -ICLT Program
Module 4: Burden of Disease Tutorial Slides S2 2025
Microbial disease of the cardiovascular and lymphatic systems
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Anesthesia in Laparoscopic Surgery in India
Cell Structure & Organelles in detailed.
2.FourierTransform-ShortQuestionswithAnswers.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Microbial diseases, their pathogenesis and prophylaxis
Final Presentation General Medicine 03-08-2024.pptx
TR - Agricultural Crops Production NC III.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Complications of Minimal Access Surgery at WLH
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
GDM (1) (1).pptx small presentation for students
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Abdominal Access Techniques with Prof. Dr. R K Mishra
Institutional Correction lecture only . . .

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