0

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);
	
	}
}

?>
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by coolest_987
0

Remove isset from $_REQUEST in delete code.

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

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

0

<?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
?>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.