<?php if(isset($_REQUEST['action'])) 
              {
              	$value=$_REQUEST['check'];
              	foreach($value as $ids)
              	{
              		$mdelete="DELETE FROM songs WHERE id='".$ids."'";
              		mysql_query($mdelete);
              	}
              } ?>
Member Avatar
diafol

DOn't use $_REQUEST if you can help it. Be specific with $_POST or $_GET.

The error is because when you post data, it is in a single string. the foreach needs an array.
perhaps use an explode() on the input

Hi ahsan1,

I suggest you to print_r first your variable "$_REQUEST" and if its getting value(not empty array) then only will go ahead with delete query.

It might be possible that you not getting any data and still trying to delete it.

Tips: In such cases, go ahead step by step with "echo" your query.

why dont u use this for deletion of record

if($act == "Delete")// act is name of submit buttn and delete is value of that button
 {
   if(isset($checkbox)) // checkbox for selection of records to be deleted
    { 
      for($i=0;$i<count($checkbox);$i++) // for loop
	{
	  $sql="delete from tablename where id = $checkbox[$i]";					
	     if(mysql_query($sql)){
		$Message="Record deleted successfully."; // success message
	     }else{
		$Message="Unable to delete record(s) at the moment. Technical suport required.";   //failuer message
}
        }
			
		}else{
			$Message="Please select record(s) to delete.";
		}
	}