Jessie Jessie - 5 months ago 12
PHP Question

PHP int checking not working

Well, I've tried making a rank system but it doesn't seem to work?
I'm new but learning please take it easy on me.
Here is where I check for users info

GetInfo.php


# Check if user is valid
session_start();
if(!isset($_SESSION['username'])) {
header('location: login.php');
die();
} else {
$my_username = $_SESSION['username'];
}

# Get User Information
$db_get_user = mysqli_query($con, "SELECT * FROM users WHERE username='$my_username'");
# Get The User Information
$row = mysqli_fetch_array($db_get_user);
$my_email = $row['email'];
if($my_rank = $row['rank'] = 0){
echo '000';
}else if($my_rank = $row['rank'] = 1){
echo '111';
}else if($my_rank = $row['rank'] = 2){
echo '222';
}else if($my_rank = $row['rank'] = 3){
echo '333';
}else if($my_rank = $row['rank'] = 4){
echo '444';
}else if($my_rank = $row['rank'] = 5){
echo '555';
}

?>

Answer

Are you simply trying to set $my_rank equal to $row['rank']?

$my_rank = $row['rank'];
if($my_rank == 0){
    echo '000';
}else if($my_rank == 1){
    echo '111';
}else if($my_rank == 2){
    echo '222';
}else if($my_rank == 3){
    echo '333';
}else if($my_rank == 4){
    echo '444';
}else if($my_rank == 5){
    echo '555';
}