I have this code and it works.
function del_admins($id, $del) {
include '../lib/config.php';
connect();
$result = mysql_query("SELECT * FROM admin");
$total_admins = mysql_num_rows($result);
if ($total_admins == "1") {
CPMessage("Error Deleting Administrator", "Currently there is only one administrator, so the account cannot be removed.");
}
if ($del == "") {
main();
}
foreach($del as $id){
$result = mysql_query ("DELETE FROM `admin` WHERE `id` = '".$id."'");
}
CPMessage("Administrator(s) Deleted", "The selected administrator(s) has been deleted.");
}
Okay so my problem?
Well everything works fine. It doesn't let me delete rows if there is one left, which is the way I coded it. The problem-- if I try to delete all of them at the same time, it deletes them all. How do I prevent that from happening?