如果行具有重定向,请检查行是否具有任何值

I am trying to set an if statement on the page where you choose a " class " to play. What i want to check is if the row pathoption has any value set, and if it has redirect to the homepage and if it doesnt have any value set dont redirect. Currently im setting a username in the both the user and "stats" table on register. The problem i have is that it redirects to whatever i have set in the if statement.

Here is my code:

//CREATE CONNECTION
    $conn = new mysqli($dbserver, $dbusername, $dbpassword, $db);
  $username = $_SESSION['loggedin'];
// CHECK CONNECTION
if ($conn->connect_error)
{
    die("Connection Failed: ".$conn->connect_error);
}

$query = "SELECT pathoption from stats where username='$username'";
$result = mysqli_query($conn, $query);

if(mysqli_num_rows($result) > 0)
{
    header('location:../../index.php?page=home');
}

mysqli_num_rows only returns the number of rows in a result set, I'm assuming that you want to check if pathoption is empty or not, here is an example:

if(mysqli_num_rows($result) > 0) {

    $row = mysqli_fetch_assoc($result);

    if ( !empty($row['pathoption']) ) {
        header('location:../../index.php?page=home');
    }

}

Note: your code is vulnerable against SQL injection, You have to use prepared statements.