title: Delete selected row from table in php
body: <p>I am using the code (pasted below) to delete the record from the table when it's selected by the <code>checkbox</code>. It is working, but it is not deleting the record from the table, it is only showing the <code>echo</code> "Records deleted Successfully.".</p>
  
  <p>Please have a look at my code and suggest me some changes.</p>
  
  <pre><code>&lt;?php
  echo "Hiiiiiiiiii";
  include("conn.php");
  $sql="select * from test ";
  
  $res=mysql_query($sql) or die(mysql_error());
  ?&gt;
  
  &lt;form name="form1" method="POST" action=""&gt;
      &lt;table width="578" border="1" align="center" id="menu"&gt;
      &lt;tr&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;id&lt;/th&gt;
      &lt;th&gt;Name&lt;/th&gt;
      &lt;th&gt;email&lt;/th&gt;
      &lt;th&gt;phno&lt;/th&gt;
   &lt;/tr&gt;
  
  &lt;?php
   while($row=mysql_fetch_array($res))
   {
  ?&gt;
  
   &lt;tr&gt;
  
      &lt;td&gt;&lt;input name="checkbox[]" type="checkbox" id="checkbox[]" value="&lt;? echo $rows['id']; ?&gt;"&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['id'];?&gt;&lt;/td&gt;
  
      &lt;td&gt;&lt;?php echo $row['name'];?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['emailid'];?&gt;&lt;/td&gt;
  
      &lt;td&gt;&lt;?php echo $row['phno'];?&gt;&lt;/td&gt;
      &lt;?php
      echo"&lt;td&gt;&lt;a href='update.php?id=".$row['id']."'&gt;Update&lt;/a&gt;&lt;/td&gt;";
      ?&gt;
   &lt;?php
    }
   ?&gt;  
   &lt;tr&gt;&lt;td&gt;&lt;input type="submit" name="delete" value="Delete" id="delete"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tr&gt;&lt;/table&gt;
  
   &lt;?php
  // Check if delete button active, start this
  $count = mysql_num_rows($res);
  echo "$count";
  
  if(isset($_POST['delete']))
      {
           $delete_id = $_POST['checkbox'];
           $id = count($delete_id );
           if (count($id) &gt; 0)
            {
               foreach ($delete_id as $id_d)
               {
                  $sql = "DELETE FROM `test` WHERE id='$id_d'";
                  $delete = mysql_query($sql);
              }
          }
          if($delete)
          {
              echo $id." Records deleted Successfully.";
          }
      }
  &gt;?
  </code></pre>