Hi,
I'm trying to put together a page that deletes records from a database based on if an item is unticked, I've got the existing items in an array (let's call it array1 for the sake of argument):
and the remaining items after the form has been submitted in and array called array2:
I then try and compare the arrays using array_diff and delete the remaining arrays from the database by doing the following:
[PHP]
foreach (array_diff($ar ray1, $array2) as $delete) {
$query = "DELETE FROM database WHERE wasteid = '$delete' AND id = '$id' ";
mysql_query($qu ery)
or die(mysql_error ());
}
[/PHP]
But it doesn't seem to work! Any ideas?
Cheers
I'm trying to put together a page that deletes records from a database based on if an item is unticked, I've got the existing items in an array (let's call it array1 for the sake of argument):
Code:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] => 11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 )
Code:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] => 11 )
[PHP]
foreach (array_diff($ar ray1, $array2) as $delete) {
$query = "DELETE FROM database WHERE wasteid = '$delete' AND id = '$id' ";
mysql_query($qu ery)
or die(mysql_error ());
}
[/PHP]
But it doesn't seem to work! Any ideas?
Cheers
Comment