-2

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';
    }

?>
Jessie
  • 1
  • 1
  • `=` is assignment, `==` is comparison. – Rajdeep Paul Jun 29 '16 at 00:58
  • Welcome to Stack Overflow! Please see [ask] and [The perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/). What exactly does "not work" mean? Also see: http://stackoverflow.com/q/2063480/3933332 – Rizier123 Jun 29 '16 at 00:58
  • `if($my_rank == 1 && $row['rank'] == 1)` – ArtisticPhoenix Jun 29 '16 at 01:02
  • @ArtisiticPhoenix that doesn't seem to work? – Jessie Jun 29 '16 at 01:05
  • @Jessie - what is `that` obviously you'll need to fix the rest of them such as `else if($my_rank == 2 && $row['rank'] == 2){` As well as have the correct data in the variables. – ArtisticPhoenix Jun 29 '16 at 01:07
  • I did and it didn't work? – Jessie Jun 29 '16 at 01:08
  • You should update your question then, because what you have is setting `$my_rank` to the number at the left. And I'd be surprised if it makes it past the first condition. – ArtisticPhoenix Jun 29 '16 at 01:09
  • Here is a tip, `var_export( $row );` before the beginning `if` You also might want to do `echo
    ;` before the var_export to format it.  Also you're missing the starting `
    – ArtisticPhoenix Jun 29 '16 at 01:11
  • I've included the GetInfo.php on index and I'm doing to receive the info of the rank. Not sure if I did it correctly or not? – Jessie Jun 29 '16 at 01:12

1 Answers1

0

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';
}
Nick
  • 16,066
  • 3
  • 16
  • 32