Help me please to fix this stuck code

forget it, this my table =

uid | email | gcm_id | app_type | categories

 1    demo@gmail.com xzxzxzxz    A           2,5,6

`the code :

if (!empty($cat)) {
        foreach ($cat as $key => $value) {
            $wc.="FIND_IN_SET('$value',categories) > 0 OR ";
        }
    }

    $pos = strrpos($wc, "OR");

    if ($pos !== false) {
        $wc = substr_replace($wc, "AND", $pos, strlen("OR"));
    }

    $wc.=" is_active=1";


    $q = "select * from datanotif where app_type='$type' AND $wc ";

  
    $r = mysqli_query($mysqli,$q);
    $users = array();
    while ($row1 = mysqli_fetch_assoc($r)) {
        $users[] = $row1;
    }
    
    $ids = array();
foreach ($users as $key => $value) {
    $ids[] = $value['gcm_id'];
}`