title: Updating and deleting in a same html form
body: <p>I have added update and delete button in the same form using following codes. Deletion is working perfectly. But updating is again not taking the value of "id". </p>
  
  <pre><code>        &lt;?php
  $servername = "localhost";
  $username = "root";
  $password = "";
  $dp = "tool";
  
  $dp= new mysqli($servername, $username, $password, $dp) or die("Unable to connect");
  //echo"Great work";
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
       &lt;title&gt;registration&lt;/title&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;link href="site.css" rel="stylesheet"&gt;
  &lt;div align="center"&gt;
  
      &lt;link rel="stylesheet" href="mine.css"/&gt;
  
       &lt;table border="0" align="center" style="border-spacing: 40px 20px;"&gt;
  
            &lt;align="center"&gt;  &lt;td&gt;
      &lt;/head&gt;  
  
   &lt;body bgcolor=" #b3ffe0"&gt;
  
  &lt;style&gt;
  
  html {
      font-family: "Lucida Sans", sans-serif;
  }
  ul li {display: block;position: relative;float: left;border:1px }   
   ul li a {display: block;text-decoration: none; white-space: nowrap;color: #fff;}
  
     ul {
      list-style-type: none;
      padding: 2px ;
      margin-left: auto;
      background-color: #666;
  }
  
  li a, .dropbtn {
      display: inline-block;
      color: white;
      text-align: center;
      padding: 10px 20px;
      text-decoration: none;
  
  }
  li a:hover, .dropdown:hover .dropbtn {
      background-color: #111;
  }
  
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
   &lt;form method="post"&gt;
  
  &lt;ul&gt;
    &lt;li&gt;&lt;a class="active" href="df1.php"&gt;Disease&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="drug.php" &gt;Drug&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#about"&gt;Interaction&lt;/a&gt;&lt;/li&gt;
      &lt;a href="#" class="dropbtn"&gt;Alternate Drug&lt;/a&gt;
       &lt;/ul&gt;
    &lt;?php
                  $query = "SELECT * FROM disease;";
                  $result = mysqli_query($dp, $query);
                  echo "&lt;table border=5&gt;
                  &lt;tr&gt;
                  &lt;th&gt;Disease ID&lt;/th&gt;
                  &lt;th&gt;Disease&lt;/th&gt;
                  &lt;th&gt;Sub Disease&lt;/th&gt;
                  &lt;th&gt;Associated Disease&lt;/th&gt;
                  &lt;th&gt;Ethinicity&lt;/th&gt;
                  &lt;th&gt;Source&lt;/th&gt;
                  &lt;th&gt;Edit&lt;/th&gt;
                  &lt;/tr&gt;";
                  while($row = mysqli_fetch_assoc($result)) {
                      echo "&lt;tr&gt;";
  echo "&lt;td&gt;".$row{'id'}."&lt;/td&gt;";
  echo "&lt;td&gt;".$row{'Disease'}."&lt;/td&gt;";
  echo "&lt;td&gt;".$row{'SubDisease'}."&lt;/td&gt;";
  echo "&lt;td&gt;".$row{'Associated_Disease'}."&lt;/td&gt;";
  echo "&lt;td&gt;".$row{'Ethinicity'}."&lt;/td&gt;";
  echo "&lt;td&gt;".$row{'Source'}."&lt;/td&gt;";
  echo "&lt;td&gt;&lt;input type='radio' name='id' value='".$row[id]."'&gt;&lt;/td&gt;";
  echo "&lt;/tr&gt;";}
  
  echo "&lt;/table&gt;"; 
      //  $selectedRow=$_POST['id'];  
  
    ?&gt;
  
   &lt;div&gt;
      &lt;table border="0" align="center" style="border-spacing: 40px 30px;"&gt;
  
      &lt;TABLE BORDER="0" CELLSPACING="0" CELLPADDING="4" WIDTH="40%"&gt;
  
  
  
  &lt;/br&gt;&lt;center&gt;
            &lt;button style="color: red"&gt;&lt;a href="adddf1.php" target="_self" name="Add" value="Add"&gt;Add&lt;/a&gt;&lt;/button&gt;
            &lt;input type = 'submit' value = 'Update' name = 'submitupdate'&gt;
             &lt;input type = 'submit' value = 'Delete' name = 'submitdelete'&gt;
  
  
          &lt;/center&gt;&lt;/TABLE&gt;
  
      &lt;?php
      if(isset($_POST[submitupdate]))
      {
          header ("Location: http://localhost/card/edit3.php");
      }
      if ($_POST[submitdelete])
  {
      $conn = mysqli_connect('localhost','root','','tool');
  
  // Check connection
  if (!$conn) {
      die("Connection failed: " . mysqli_error());
  } 
  
  // 
       $sql="DELETE FROM disease WHERE id=".$_POST['id'];
       echo "Data deleted successfully";
  mysqli_query($conn, $sql);
  mysqli_close($conn);
  }
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Edit3.php</p>
  
  <pre><code>&lt;?php
  
  $conn = mysqli_connect('localhost','root','','tool');
  
  // Check connection
  if (!$conn) {
      die("Connection failed: " . mysqli_error());
  } 
  $query = "SELECT * FROM disease where id=".$_POST['id'];
  $result = mysqli_query($conn, $query);
  $count= mysqli_num_rows($result);
  $row = mysqli_fetch_assoc($result);
  echo $count;
  ?&gt;
  &lt;form action="update.php" method="post"&gt;
  &lt;input type="hidden" value="&lt;?php echo $row['id'];?&gt;" name="id"/&gt;
  Disease (ICD10) &lt;select id= "Disease" name="Disease"&gt;
               &lt;option value="Certain infectious and parasitic diseases"&gt;Certain infectious and parasitic diseases&lt;/option&gt;
                      &lt;option value="Neoplasms"&gt;Neoplasms&lt;/option&gt;
                      &lt;option value="Diseases of the blood and blood-forming organs and certain disorders involving the immune mechanism "&gt;Diseases of the blood and blood-forming organs and certain disorders involving the immune mechanism&lt;/option&gt;
  SubDisease&lt;input type="text" name="SubDisease" value="&lt;?php echo $row['SubDisease'];?&gt;"/&gt;
  Associated Disease&lt;input type="text" name="Associated_Disease" value="&lt;?php echo $row['Associated_Disease'];?&gt;"/&gt;
  &lt;td&gt;Ethinicity&lt;input type="text" list="Ethinicity" id="color" name="Ethinicity"  value="&lt;?php echo $row['Ethinicity'];?&gt;" style="width:100px;"&gt;
  &lt;datalist id="Ethinicity"&gt;
  &lt;option value="Indian"&gt;
  &lt;option value="American"&gt;
  &lt;option value="Srilankan"&gt;
  &lt;/datalist&gt;
           &lt;/td&gt;
  Source&lt;input type="text" name="Source" value="&lt;?php echo $row['Source'];?&gt;"/&gt;
  &lt;input type="submit" value="update"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>update.php</p>
  
  <pre><code>&lt;?php
  $conn = mysqli_connect('localhost','root','','tool');
  
  // Check connection
  if (!$conn) {
      die("Connection failed: " . mysqli_error());
  } 
  $disease = $_POST['Disease'];
  $SubDisease = $_POST['SubDisease'];
  $Associated_Disease = $_POST['Associated_Disease'];
  $Ethinicity = $_POST['Ethinicity'];
  $Source = $_POST ['Source'];
  $id = $_POST ['id'];
  
  $update= "Update disease set Disease='".$disease."', SubDisease='".$SubDisease."', Associated_Disease='".$Associated_Disease."', Ethinicity='".$Ethinicity."', Source='".$Source."' where id=".$_POST["id"];
  
  if(!mysqli_query($conn,$update))
      echo mysqli_error;
  ?&gt;
  </code></pre>
  
  <p>And drop down of Disease, is also not getting reading the databse value and not getting display in the editing page.</p>