<?php 
include('dbcon.php');

if(isset($_POST['id'])){
    $id = $_POST['id'];
    $ref = "Users/";
    $fetchdata = $database->getReference($ref)->getValue();
    $i = 0;
    foreach ($fetchdata as $key => $row){
       
        if($row['state'] == $id && $row['roles'] == 1){
            $i++;
        }
       
    }
    echo $i;
}


?>