HI
i am try to delete multiple data by using check-box in php
i tried but is don't works not getting the ids from the check-box..
my code is

<tbody> 
<?php while ($row = mysql_fetch_array($res)) { ?>      
    	<tr class=" <?php echo $class = ($class == 'even') ? 'odd' : 'even'; ?>"  >
        	<td><input type="checkbox" name="checkbox[]" value="<?php echo $row['grievance_id']; ?>"/></td>
        	<td><?php echo $row['grievance_id']; ?></td>
            <td><?php echo $row['grievance_reason']; ?></td>
            <td align="center"><?php echo $row['grievance_meeting']; ?></td>
            <td align="center"><?php echo $row['next_review']; ?></td>
            <td align="center"><?php if($row['matter_resolved'] == 1)
									{  echo "Yes";  }else{  echo "No";  } ?>
            </td>
        </tr>
<?php } } ?>        
    </tbody>
</table>

</form>

<?php 
if(isset($_POST['action']) == "gdelete")
{

		$checkbox = isset($_REQUEST['checkbox']);
		$countaa = count($checkbox);
	
	for($i=0;$i<$countaa;$i++){
		echo $del_id  = $checkbox[$i];
		echo $sql = "DELETE FROM hs_hr_emp_grievances WHERE grievance_id=$del_id";
		$result = mysql_query($sql);
	
	}
}

?>

Remove isset from $_REQUEST in delete code.

$checkbox = $_REQUEST['checkbox'];
$countaa = count($checkbox);

i tried but it give me undefined index...

Post complete error with line number. and check what is exact written there on given line number.

<?php

if(isset($_POST) == "gdelete")
{
if(isset($_REQUEST)
{
$acc = $_REQUEST
foreach($acc as $ac)
{
echo $sql = "DELETE FROM hs_hr_emp_grievances WHERE grievance_id=$ac";

$result = mysql_query($sql);
}
}
}
Happy Coding
?>

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.