in my previous question i only ask how can i delete a data using checkbox i forgot to put multiple check.
here's my code
<form id="form1" name="form1" method="post" action="">
<table border='1' cellspacing='0' width='612'>
<tr>
<th bgcolor='green'><font color='white'>
<input type='checkbox' name='checkall' onclick='checkedAll();' />
</font></th>
<th bgcolor='green'><font color="white">ID</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'>Name</font></th>
<th bgcolor='green'><font color='white'>View</font></th>
<th bgcolor='green'><font color='white'>Approve</font></th>
</tr>
<?php
$i = 0;
$number = 0;
while($row = mysql_fetch_array($result)){
while($rows = mysql_fetch_array($result1)){
$number++;
?>
<?php
$i++;
if($i%2)
{
$bg_color = "#EEEEEE";
}
else {
$bg_color = "#E0E0E0";
}
?>
<script language='JavaScript'>
checked = false;
function checkedAll () {
if (checked == false){checked = true}else{checked = false}
for (var i = 0; i < document.getElementById('form1').elements.length; i++) {
document.getElementById('form1').elements[i].checked = checked;
}
}
</script>
<tr bgcolor='". $bg_color ."'>
<td><center>
<strong><font color='red'>
<input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['cno']; ?>" />
</font></strong>
</center></td>
<td><center>
<strong><font color='red'><?php echo $rows['code']; ?></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><font color='blue'><?php echo $rows['lname'] .', '. $rows['fname'] ?></font></strong>
</center></td>
<td><center><strong><a href='edit.php?code=<?php echo $row[cno]; ?>' class="style6">View</a></strong>
</center></td>
<td><center><Strong><a href='sendmail.php?emailadd=<?php echo $row[emailadd]; ?>' class="style6">Approve</a></Strong>
</center></td>
</tr>
<?php } }?>
</table>
<div class="select"><strong>Other Pages: </strong>
<select name="select">
<option>1</option>
</select>
</div>
<input name="delete" type="submit" id="delete" value="Delete" />
<?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";
$sql1 = "DELETE from guest where code = $del_id";
$result1 = mysql_query($sql1) or die (mysql_error());
$result = mysql_query($sql) or die (mysql_error());
}
if($result)
{
header('Location: admin.php');
}
else
{
echo "Error: ".mysql_error();
}
}
?>
i can delete only 1 record. i want 2 or more data to delete if the checkbox is check. thanks