SQL查询(select * where)在php中不起作用

    <?php
$mysqli_host = 'localhost';
$mysqli_user = 'root';
$mysqli_pass = '';
$mysqli_db = 'fives';

$link = mysqli_connect($mysqli_host,$mysqli_user,$mysqli_pass,$mysqli_db);

if (isset($_GET['username'])) {
    $username = mysqli_real_escape_string($link,$_GET['username']);
    print $username. "<br>";
    if (!empty($username)) {
        $username_query = mysqli_query($link,"SELECT * FROM users");
            while($row = mysqli_fetch_array($username_query)) {
                print "username: " . $row["username"]. " - password: " . $row["Password"]. " - date:" . $row["date"]. "<br>";
            }
            print $username_result = mysqli_num_rows($username_query) . "<br>";//print 1

            $username_query = mysqli_query($link,"SELECT * FROM users WHERE username = '" . $username . "'");
            while($row = mysqli_fetch_array($username_query)) {
                print "username: " . $row["username"]. " - password: " . $row["Password"]. " - date:" . $row["date"]. "<br>";
            }
            print $username_result = mysqli_num_rows($username_query);//print 0
    }
}
?>

what it prints is

yariv
username: "yariv" - password: "1234" - date:2015-08-26
1
0

well there's no problem with the first query.. it gets all of the data from [Users] which is 1 row, but when im trying to get it by using where username = '" . $username . "' the sql query gets 0 rows. why is it like that?

The first query shows the result because you did not compare the given user name to the username existing in the database, but in the second query you were cheeking the username to the database username. so are you sure that you gave the correct user name same as the username in the database?