仅当类别没有子类别时才尝试删除类别

I have categories and subcategories and Im trying to do a system like if I want to remove a category I only can do that if I remove my subcategories first.

My subcategories have the id_father of the categories.

Like this:

(Warnings and Technology are the Categories)

enter image description here

My Problem:

When I remove a category with subcategories not appear my error message that I have in code below (This category has subcategories) and the category is in fact removed from my database.

I have reviewed the code many times but I can not understand where the error is.

Can you please give me a little help?

My php code:

if(!empty($_GET['deleteCategory']))
    {   
     $idDel = $_GET['deleteCategory'];
     $readDeleteCategory = $pdo->prepare("SELECT * FROM categories where id_father = ?");  
     $readDeleteCategory->bindValue(1, $idDel);
     $num_rows_ReadDeleteCategory = $readDeleteCategory->rowCount();
     //if dont return results we have the delete and show the message
    if(! $num_rows_ReadDeleteCategory >=1)
        {
        $deleteCategory = $pdo->prepare("DELETE FROM categories WHERE id =?");
        $deleteCategory->bindValue(1,$idDel);
        $deleteCategory->execute();
        echo 'category removed with sucess.';   
            }
    else
        {
        echo 'This category has subcategories. Remove subcategories first.';
        }
     }


if(!empty($_GET['deleteSubcategory']))
    {
    $idDel = $_GET['deleteSubcategory'];
    $deleteCategory = $pdo->prepare("DELETE FROM categories WHERE id =?");
    $deleteCategory->bindValue(1,$idDel);
    $deleteCategory->execute();
    echo 'Category removed with sucess.';
    }

I think you're just missing a simple line.

 $readDeleteCategory->bindValue(1, $idDel);
 $readDeleteCategory->execute();
 $num_rows_ReadDeleteCategory = $readDeleteCategory->rowCount();