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

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

6
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by kamran_FrizCon
0

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

0

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.

0

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.";
		}
	}

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

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.