Fatal error: Uncaught TypeError: mysqli_num_rows(): Argument #1 [duplicate]

I have an error on MySQL command which I have used in PHP command. here is the code

$sql1 ="SELECT CASE WHEN count1 = 0 THEN UPDATE tpl_loan SET loan_status='2' WHERE loan_app_no = '$loan_app_no' ELSE 'mis-matched' END 
                        FROM ( SELECT (SELECT COUNT(*) FROM tpl_loan_guarantor WHERE loan_app_no ='$loan_app_no' and status='1') AS count1 ) AS counts";
                        $results1 = mysqli_query($dbt,$sql1);
                        if(mysqli_num_rows($results1) > 0){
                        
                        
                         echo "<script>alert('You have a pending loan');</script>"; 
                        echo "<script>window.location.href='login'</script>";
                        
                        }

I get error

Fatal error: Uncaught TypeError: mysqli_num_rows(): Argument #1 ($result) must be of type mysqli_result, bool given

Please help me where I got I wrong