简体   繁体   中英

if statement in PHP

The word "true" is in the database where its getting the data from, but the if statement is going to the else.

while(odbc_fetch_row($user)){
    echo "<div style='position:absolute;overflow:scroll;height:370px;'>";
    $name         = odbc_result($user, 'username');
    $email        = odbc_result($user, 'email');
    $admin        = odbc_result($user, 'admin');
    $lastLogin    = odbc_result($user, 'lastLogin');
    $userDisabled = odbc_result($user, 'disabled');
    $fullname     = odbc_result($user, 'firstName') . " " . odbc_result($user, 'lastName');

    echo "<br><h2> " . $name . "</h2>";
    echo $fullname . "<br>";
    echo " " . $email;
    echo "<br>Last Login Time: <br>" . $lastLogin;
    echo "<br>";

    if($userDisabled == "true"){
        echo "<input type='checkbox' class='disableUser' checked id='disableUser'>Disable User<br>";
    }else{
        echo "<input type='checkbox' class='disableUser' id='disableUser' >Disable User<br>";
    }

    echo "<br>";
}

so try with this :

if((is_bool($userDisabled) && $userDisabled === TRUE) || (is_string($userDisabled) && strtoupper($userDisabled) == "TRUE" ) {
# do your job
}else {
# you can eat or sleep :)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM