SlideShare a Scribd company logo
1 of 8
3.Create connection.php file
<?php
// Enter your Host, username, password, database below.
// I left password empty because i do not set password on localhost.
$con=mysqli_connect('localhost','root','','myprograming') or die("connection failed :
".mysqli_connect_error());
if ($con) {
// echo "Connection Successfully";
}
else{
echo "Sorry Some Mistakes is";
}
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
4.Create index.php file
<!DOCTYPE html>
<html>
<head>
<title>insert</title>
</head>
<body>
<div class="row text-center">
<div class="container">
<h1>Insert DATA</h1>
<form action="index.php" method="post">
<input type="text" name="firstname" placeholder="firstname"><br><br>
<input type="text" name="lastname" placeholder="lastname"><br><br>
<input type="gmail" name="gmail" placeholder="gmail"><br><br>
<input type="text" name="number" placeholder="number"><br><br>
<input type="text" name="address" placeholder="address"><br><br>
<input type="submit" name="submit" value="insert"><br><br>
</form>
<button><a href="show.php">show data</a></button>
</div>
</div>
</body>
</html>
<?php
error_reporting(0);
include 'connection.php';
if (isset($_POST['submit'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$gmail = $_POST['gmail'];
$number = $_POST['number'];
$address = $_POST['address'];
$sql = "INSERT INTO `reg` VALUES ('$id','$firstname','$lastname','$gmail','$number','$address')";
$data=mysqli_query($con,$sql);
if ($data) {
echo "insert";
}else
{
echo "sorry";
}
}
?>
5.Create show.php file
<!DOCTYPE html>
<html>
<head>
<title>show table</title>
</head>
<body>
<?php
include ('connection.php');
$sql ="select * from reg";
$data =mysqli_query($con,$sql);
$total=mysqli_num_rows($data);
if ($total=mysqli_num_rows($data)) {
?>
<table border="2">
<tr>
<th>id</th>
<th>firstname</th>
<th>lastname</th>
<th>gmail</th>
<th>number</th>
<th>address</th>
<th>delete</th>
<th>update</th>
</tr>
<?php
while ($result = mysqli_fetch_array($data)) {
echo "
<tr>
<td>".$result['id']."</td>
<td>".$result['firstname']."</td>
<td>".$result['lastname']."</td>
<td>".$result['gmail']."</td>
<td>".$result['number']."</td>
<td>".$result['address']."</td>
<td><a href='update.php?id=$result[id] & firstname=$result[firstname]
& lastname=$result[lastname] & gmail=$result[gmail] & number=$result[number]
&address=$result[address]'> update </a></td>
<td><a href='delete.php?id=$result[id] '>delete </a></td>
</tr>
";
}
}
else
{
echo "no record found";
}
?>
</table>
</body>
</html>
<!--------- echo "<br>".$result['id']." ".$result['firstname']." ".$result['lastname']." ".$result['gmail']."
".$result['number']." ".$result['address']."<br>";_----->
6.Create update.php file
<!DOCTYPE html>
<html>
<head>
<title>update</title>
</head>
<body>
<form action="" method="get">
<input type="text" name="id" placeholder="id" value="<?php echo $_GET['id']; ?>"><br><br>
<input type="text" name="firstname" placeholder="firstname" value="<?php echo
$_GET['firstname']; ?>"><br><br>
<input type="text" name="lastname" placeholder="lastname" value="<?php echo
$_GET['lastname']; ?>" ><br><br>
<input type="gmail" name="gmail" placeholder="gmail" value="<?php echo $_GET['gmail'];
?>"><br><br>
<input type="text" name="number" placeholder="number" value="<?php echo
$_GET['number']; ?>"><br><br>
<input type="text" name="address" placeholder="address" value="<?php echo
$_GET['address']; ?>"><br><br>
<input type="submit" name="submit" value="update">
</form>
<?php
error_reporting(0);
include ('connection.php');
if ($_GET['submit'])
{
$id = $_GET['id'];
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$gmail = $_GET['gmail'];
$number = $_GET['number'];
$address = $_GET['address'];
$sql="UPDATE reg SET firstname='$firstname' , lastname='$lastname', gmail='$gmail' ,
number='$number', address='$address' WHERE id='$id'";
$data=mysqli_query($con, $sql);
if ($data) {
//echo "record update";
header('location:show.php');
}
else{
echo "not update";
}
}
else
{
echo "click on button to save the change";
}
?>
</body>
</html>
7.Create delete.php file
<?php
include ('connection.php');
$id = $_GET['id'];
$sql ="DELETE FROM `reg` WHERE id='$id'";
$data = mysqli_query($con,$sql);
if ($data) {
echo "deleted";
header('location:show.php');
}else
{
echo "error";
}
?>

More Related Content

Similar to CRUD OPERATIONS using MySQL connectivity in php

The HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageThe HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageLovely Professional University
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in phpherat university
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
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
 
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
 
how would i fix my code- any login doesnt work but it should retrieve.docx
how would i fix my code- any login doesnt work but it should retrieve.docxhow would i fix my code- any login doesnt work but it should retrieve.docx
how would i fix my code- any login doesnt work but it should retrieve.docxJacobUasThomsoni
 
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
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Database presentation
Database presentationDatabase presentation
Database presentationwebhostingguy
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Intro to php
Intro to phpIntro to php
Intro to phpSp Singh
 

Similar to CRUD OPERATIONS using MySQL connectivity in php (20)

The HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageThe HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup language
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in php
 
Diving into php
Diving into phpDiving into php
Diving into php
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
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
 
18.register login
18.register login18.register login
18.register login
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
 
Php talk
Php talkPhp talk
Php talk
 
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
 
how would i fix my code- any login doesnt work but it should retrieve.docx
how would i fix my code- any login doesnt work but it should retrieve.docxhow would i fix my code- any login doesnt work but it should retrieve.docx
how would i fix my code- any login doesnt work but it should retrieve.docx
 
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
 
Php (1)
Php (1)Php (1)
Php (1)
 
Stored Procedure
Stored ProcedureStored Procedure
Stored Procedure
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Database connectivity in PHP
Database connectivity in PHPDatabase connectivity in PHP
Database connectivity in PHP
 
Python my sql database connection
Python my sql   database connectionPython my sql   database connection
Python my sql database connection
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Database presentation
Database presentationDatabase presentation
Database presentation
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Intro to php
Intro to phpIntro to php
Intro to php
 

More from KavithaK23

PHP record- with all programs and output
PHP record- with all programs and outputPHP record- with all programs and output
PHP record- with all programs and outputKavithaK23
 
PHP Lab template for lecturer log book- and syllabus
PHP Lab template for lecturer log book- and syllabusPHP Lab template for lecturer log book- and syllabus
PHP Lab template for lecturer log book- and syllabusKavithaK23
 
Unit 4 - 2.docx
Unit 4 - 2.docxUnit 4 - 2.docx
Unit 4 - 2.docxKavithaK23
 
unit 4 - 1.pdf
unit 4 - 1.pdfunit 4 - 1.pdf
unit 4 - 1.pdfKavithaK23
 
unit 2 -program security.pdf
unit 2 -program security.pdfunit 2 -program security.pdf
unit 2 -program security.pdfKavithaK23
 

More from KavithaK23 (10)

PHP record- with all programs and output
PHP record- with all programs and outputPHP record- with all programs and output
PHP record- with all programs and output
 
PHP Lab template for lecturer log book- and syllabus
PHP Lab template for lecturer log book- and syllabusPHP Lab template for lecturer log book- and syllabus
PHP Lab template for lecturer log book- and syllabus
 
unit 3.pdf
unit 3.pdfunit 3.pdf
unit 3.pdf
 
Unit III.docx
Unit  III.docxUnit  III.docx
Unit III.docx
 
Unit 4 - 2.docx
Unit 4 - 2.docxUnit 4 - 2.docx
Unit 4 - 2.docx
 
unit 4 - 1.pdf
unit 4 - 1.pdfunit 4 - 1.pdf
unit 4 - 1.pdf
 
unit 5 -2.pdf
unit 5 -2.pdfunit 5 -2.pdf
unit 5 -2.pdf
 
unit 5 -1.pdf
unit 5 -1.pdfunit 5 -1.pdf
unit 5 -1.pdf
 
UNIT 5.docx
UNIT 5.docxUNIT 5.docx
UNIT 5.docx
 
unit 2 -program security.pdf
unit 2 -program security.pdfunit 2 -program security.pdf
unit 2 -program security.pdf
 

Recently uploaded

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

CRUD OPERATIONS using MySQL connectivity in php

  • 1. 3.Create connection.php file <?php // Enter your Host, username, password, database below. // I left password empty because i do not set password on localhost. $con=mysqli_connect('localhost','root','','myprograming') or die("connection failed : ".mysqli_connect_error()); if ($con) { // echo "Connection Successfully"; } else{ echo "Sorry Some Mistakes is"; } // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?> 4.Create index.php file <!DOCTYPE html> <html> <head> <title>insert</title>
  • 2. </head> <body> <div class="row text-center"> <div class="container"> <h1>Insert DATA</h1> <form action="index.php" method="post"> <input type="text" name="firstname" placeholder="firstname"><br><br> <input type="text" name="lastname" placeholder="lastname"><br><br> <input type="gmail" name="gmail" placeholder="gmail"><br><br> <input type="text" name="number" placeholder="number"><br><br> <input type="text" name="address" placeholder="address"><br><br> <input type="submit" name="submit" value="insert"><br><br> </form> <button><a href="show.php">show data</a></button> </div> </div> </body> </html> <?php error_reporting(0); include 'connection.php'; if (isset($_POST['submit'])) { $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $gmail = $_POST['gmail'];
  • 3. $number = $_POST['number']; $address = $_POST['address']; $sql = "INSERT INTO `reg` VALUES ('$id','$firstname','$lastname','$gmail','$number','$address')"; $data=mysqli_query($con,$sql); if ($data) { echo "insert"; }else { echo "sorry"; } } ?> 5.Create show.php file <!DOCTYPE html> <html> <head> <title>show table</title> </head> <body> <?php include ('connection.php'); $sql ="select * from reg"; $data =mysqli_query($con,$sql); $total=mysqli_num_rows($data);
  • 4. if ($total=mysqli_num_rows($data)) { ?> <table border="2"> <tr> <th>id</th> <th>firstname</th> <th>lastname</th> <th>gmail</th> <th>number</th> <th>address</th> <th>delete</th> <th>update</th> </tr> <?php while ($result = mysqli_fetch_array($data)) { echo " <tr> <td>".$result['id']."</td> <td>".$result['firstname']."</td> <td>".$result['lastname']."</td> <td>".$result['gmail']."</td> <td>".$result['number']."</td> <td>".$result['address']."</td> <td><a href='update.php?id=$result[id] & firstname=$result[firstname] & lastname=$result[lastname] & gmail=$result[gmail] & number=$result[number] &address=$result[address]'> update </a></td>
  • 5. <td><a href='delete.php?id=$result[id] '>delete </a></td> </tr> "; } } else { echo "no record found"; } ?> </table> </body> </html> <!--------- echo "<br>".$result['id']." ".$result['firstname']." ".$result['lastname']." ".$result['gmail']." ".$result['number']." ".$result['address']."<br>";_-----> 6.Create update.php file <!DOCTYPE html> <html> <head> <title>update</title> </head>
  • 6. <body> <form action="" method="get"> <input type="text" name="id" placeholder="id" value="<?php echo $_GET['id']; ?>"><br><br> <input type="text" name="firstname" placeholder="firstname" value="<?php echo $_GET['firstname']; ?>"><br><br> <input type="text" name="lastname" placeholder="lastname" value="<?php echo $_GET['lastname']; ?>" ><br><br> <input type="gmail" name="gmail" placeholder="gmail" value="<?php echo $_GET['gmail']; ?>"><br><br> <input type="text" name="number" placeholder="number" value="<?php echo $_GET['number']; ?>"><br><br> <input type="text" name="address" placeholder="address" value="<?php echo $_GET['address']; ?>"><br><br> <input type="submit" name="submit" value="update"> </form> <?php error_reporting(0); include ('connection.php'); if ($_GET['submit']) { $id = $_GET['id']; $firstname = $_GET['firstname']; $lastname = $_GET['lastname']; $gmail = $_GET['gmail']; $number = $_GET['number']; $address = $_GET['address']; $sql="UPDATE reg SET firstname='$firstname' , lastname='$lastname', gmail='$gmail' , number='$number', address='$address' WHERE id='$id'";
  • 7. $data=mysqli_query($con, $sql); if ($data) { //echo "record update"; header('location:show.php'); } else{ echo "not update"; } } else { echo "click on button to save the change"; } ?> </body> </html> 7.Create delete.php file <?php include ('connection.php'); $id = $_GET['id']; $sql ="DELETE FROM `reg` WHERE id='$id'"; $data = mysqli_query($con,$sql); if ($data) { echo "deleted"; header('location:show.php');