Sharp Tutorial
delete update in php using mysql

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

PHP Introduction

  • PHP home
  • PHP introduction
  • How to install and run
  • Syntax and Rule in PHP
  • Data type and operator
  • If else in php
  • Loop in php
  • Array in php
  • Sring in php
  • Function in php
  • Include in php

Working with Forms

  • Get and Post
  • Get Form input into PHP
  • Form Validation

PHP with MySQl

  • Connect PHP & Mysql
  • Insert using PHP Mysql
  • Select using PHP MySql
  • Delete Update using PHP Mysql
  • Login Page Example in PHP

Advanced PHP

  • Session in PHP
  • Cookies in PHP
  • File Handling in PHP
  • File Upload/Download PH

Object Oriented PHP

  • Class Obejct in PHP
  • Constructor in PHP
  • Destructor in PHP
  • Inheritance in PHP

delete update mysql using php

Delete update queries may also be fired using php on sql table as shown in the followig examples

Delete records using php mysql

Student Form with Delete/Update Button

<html>
<body bgcolor="gray">
<center>
<form name="deleteupdateform" action="delete-update-student.php" >
Name<input type="text" name="sname"><br>
RollNo<input type="text" name="roll"><br>
Course<input type="text" name="course"><br>
<input type="submit" name="btn" value="delete">
<input type="submit" name="btn" value="update">
</form>
</center>
</body>
</html>

PHP page to delete or update the records based on the button clicked

<html>
 <?php
  $host="localhost";
  $dbuser = "root";
  $password = ""; // change password as per your database.
  $dbname=     "sharp_tutorial";
  $conn = mysqli_connect($host, $dbuser, $password,$dbname);
  $sname=$_GET["sname"];
  $rollNo=$_GET["roll"]; 
  $course=$_GET["course"];
  $action=$_GET["btn"];
  if($action=="delete")
  {
    $sql="delete from student where rollNo='$rollNo'";
    $msg="Record Deleteded or not exists";
  }
  if($action=="update")
  {
  $sql="update student set name='$sname',course='$course' where rollNo='$rollNo'";
    $msg="Record updaed  or not exists";
  }
  mysqli_query($conn,$sql);
  echo"$msg"; //msg based on query fired.
  ?> </html>

Above program delete the records if delete button is clicked and record exists in the table as shown below.

Above program update the records if update button is clicked and record exists in the table as shown below.

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial