i have a problem deleting a data using checkbox please help me

here's my code

admin.php

<form id="form1" name="form1" method="post" action="deleteApplication.php"><table border='1' cellspacing='0' width='612'>
<tr>
<th bgcolor='green'><font color='white'>#</font></th>
<th bgcolor='green'><font color='white'>Room No.</font></th>
<th bgcolor='green'><font color='white'>Cust. Code</font></th>
<th bgcolor='green'><font color='white'>Check In</font></th>
<th bgcolor='green'><font color='white'>Check Out</font></th>
<th bgcolor='green'><font color='white'>No of Rooms</font></th>
<th bgcolor='green'><font color='white'>Room Type</font></th>
<th bgcolor='green'><font color='white'>Function</font></th>
</tr>
					<?php
$i = 0; 

$number = 0;
while($row = mysql_fetch_array($result)){

$number++;

?>
	
 <?php
$i++;

if($i%2)
{
$bg_color = "#EEEEEE";
}
else {
$bg_color = "#E0E0E0";
}
?> 
	
   <tr bgcolor='". $bg_color ."'>
   <td><center><Strong><font color='red'><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $rows['cno']; ?>">
   </font></Strong>
   </center></td>
   <td><center><Strong><font color='red'><?php echo $row['roomno']; ?></font></Strong></center></td>
  <td><center><Strong><font color='red'><?php echo $row['cno']; ?></font></Strong></center></td>
  <td><center><Strong><?php echo $row['checkin']; ?></Strong></center></td>
  <td><center><Strong><?php echo $row['checkout'];  ?></Strong></center></td>
  <td><center><Strong><?php echo $row['noofrooms'];  ?></Strong></center></td>
  <td><center><Strong><?php echo $row['roomtype'];  ?></Strong></center></td>
  <td><div align="center"><a href='edit.php?code=<?php echo $row[cno]; ?>' class="style1"><img src="Admin/img/save-icon.gif" width="16" height="16" alt="View" title="View Information"/></a>
       <a href='sendmail.php?emailadd=<?php echo $row[emailadd]; ?>' class="style1"><img src="Admin/img/edit-icon.gif" width="16" height="16" alt="Email" title="Email"/></a></div></td>
   </tr>
 <?php } ?>
				</table>
				<div class="select"><strong>Other Pages: </strong>
					<select>
						<option>1</option>
					</select>
			  </div>
			    
			      <label>
			        <input name="delete" type="submit" id="delete" value="Delete">


		          </label></form>

deleteApplication.php

<?php
include 'dbconnect.php';
 
 if(isset($_POST['delete'])) 
	 {
 $checkbox = $_POST['checkbox']; //from name="checkbox[]"
$countCheck = count($_POST['checkbox']);
 
 for($i=0;$i<$countCheck;$i++)
		 {
			 $del_id  = $checkbox[$i];
 
 $sql = "DELETE from rent where cno = $del_id";
 $result = mysql_query($sql) or die (mysql_error());
 
		 }
			 if($result)
		 {	
				 header('Location: index.php');
			 }
			 else
			 {
 echo "Error: ".mysql_error();
			 }
	 }
 ?>

nothings happen everytime i click delete.

if(isset($_POST['delete'])) {
foreach($_POST['checkbox'] as $id){
    mysql_query("DELETE from rent WHERE cno = '.$id.'");
)
}

nothings happen :(

here's my deleteapplication.php

<?php
include 'dbconnect.php';
 
   
      if(isset($_POST['delete'])) {
   
      foreach($_POST['checkbox'] as $cno){
   
      mysql_query("DELETE from rent WHERE cno = '.$cno.'");
   }
   	  header('Location: admin.php');
		
	 }
?>

there's no deletion. T_T

i miss 1 its work now thanks :)

Still nothings happen! What are you missing!

are those members still active in here??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.