Hi, This is a code which shows all the records from database and also show EDIT and DELETE Button for each Record, Now I want only one DELETE Button for ALL Records and use check boxes to select and DELETE. Please Check this Code:

   # Connect to database
   if(!$cn) {
       die ("<br/>DB not connnected : " . mysql_error()); 
   # Select a database	
	   die(mysql_error() . "  " . mysql_errno());

# --- When edit button press --------
         if($cmd=="Edit") {
	  $res = mysql_query("SELECT * FROM Info
WHERE SiteId='$eno' ");
<form method="post" action="editdelete.php">
<br/>SiteID <input type="text" name="eno"  value="$r[0]"  />
<br/>Alias <input type="text" name="ename" value="$r[1]"/>
<br/>Code <input type="text" name="edate" value="$r[2]"/>
<br/>Long <input type="text" name="Longitude" value="$r[3]"/>
<br/>Lat <input type="text" name="Lat" value="$r[4]"/>
<br/>Address <input type="text" name="Address" value="$r[5]"/>
<br/>Region <input type="text" name="Region" value="$r[6]"/>
<br/>City <input type="text" name="City" value="$r[7]"/>
<br/>Maintained By<input type="text" name="MaintainedBy" value="$r[9]"/>
<br/>PAT Status<input type="text" name="StatusNopatPat" value="$r[10]"/>
<br/>Priority<input type="text" name="Priority" value="$r[15]"/>
<br/><input type="submit" name="cmd" value="Update"/>
<input type="submit" name="cmd" value="Cancel"/>
 # -- Delete a record --
  if($cmd=="Delete") {
  $sql = mysql_query("delete FROM Info
WHERE SiteId='$eno' ");
     echo "Record deleted";
 # -- Update a record --
  if($cmd=="Update") {
 /* $sql = mysql_query("UPDATE Info SET Alias='$ename',Code='$edate',Longitude='$Longitude',Lat='$Lat' where  
               SiteID='$eno' ");*/
$query=mysql_query("update Info set alias='$ename',code='$edate',Longitude='$Longitude',Lat='$Lat',Address='$Address',Region='$Region',City='$City',MaintainedBy='$MaintainedBy',StatusNopatPat='$StatusNopatPat',Priority='$Priority' where siteid='$eno'");

           echo "Record updated";
   # -- Show the list  - Grid
	$sql="select * from Info";
	   die ("<br/>" . mysql_error());

	 print "<table cellpadding=1 cellspacing=1 width=100% style=font-size:12px>";
print "<tr><th bgcolor=#5D9BCC>SiteID</th bgcolor=#5D9BCC><th bgcolor=#5D9BCC>Alias</th><th bgcolor=#5D9BCC>Code</th><th bgcolor=#5D9BCC>Long</th><th bgcolor=#5D9BCC>Lat</th><th bgcolor=#5D9BCC>Address</th><th bgcolor=#5D9BCC>Region</th><th bgcolor=#5D9BCC>City</th><th bgcolor=#5D9BCC>Maintained By</th><th bgcolor=#5D9BCC>PAT Status</th><th bgcolor=#5D9BCC>Priority</th><th bgcolor=#5D9BCC>Action</th></tr>";		   
	     print "<tr bgcolor=#FEE9A9><form method='post' action='editdelete.php'>";
	     print "<td>$r[0]</td><td>$r[1]</td><td>$r[2]</td><td>$r[3]</td><td>$r[4]</td><td>$r[5]</td><td>$r[6]</td><td>$r[7]</td><td>$r[9]</td><td>$r[10]</td><td>$r[15]</td><td>";
		 print "<input type='hidden' value='$r[0]' name='eno'/>";
		 print "<input type='submit' name='cmd' value='Edit'/>";
		 		 print "<input type='submit' name='cmd' value='Delete'/>";
      print "</td></form></tr>";				 
	 print "</table>";  

Please give me easiest way of doing this.
Like Hotmail Email Inbox when we checked many Emails we Simply press DELETE Button.

Add following after Line # 86

print "<input type='checkbox'

Write following at Line # 58

     foreach($_POST["delcheck"] as $delid) {
       $sql ="delete FROM Info WHERE SiteId='$delid'");
Great Example

Thanks Adapost . Its Working.
Now Please Tell me How to remove DELETE Button from each Record. and Put DELETE Button on the Top of Records.

Do you want to put DELETE button at the top of each record?
Remove it from the current location and paste

print "<input type='submit' name='cmd' value='Delete'/>";

after the line 84

print "<tr><td colspan='5'><input type='submit' name='cmd' value='Delete'/></td></tr>";

Adapost its showing Delete Button on the top of each Record.
i just need one DELETE Button above the Table Headers like Hotmail Email Account Inbox.
And When I selected 2 Records the DELETE Button only Delete the corresponding Record not Both.

Wrap up your code from line # 74 and onward with another html form tag and add the DELETE button.

Please tell me because its difficult to put Delete Button Inside the same form and When i put new Button in new Form It does not work so please please eidt this code for me. please . thanks. Adapost.

What I said earlier - Prepare your self for PHP. Don't waste your time to find code, good code, better code, and the best code.

I will learn with the passage of time. please do no be angry. thanks.
For all your Help.
Take Care.

This question has already been answered. Start a new discussion instead.