PHP/MySQL - Login system - Is it smart to SELECT the whole database?
===

I am in the process of designing a fairly simple login system, and I currently use the following code when a user attempts to log in to determine whether there is an entry in the database that matches the username that the user tries to log in with. (Later in the code, I check for matching passwords, etc.; I'm not worried about that part.)

Currently, I use SELECT to grab the entire database into a variable ($wholeUserDatabase), and then iterate through it to determine whether the 'username' field matches.

**It works** fine for now. But my database has three users right now. Will this method of grabbing the whole database into a variable become painfully slow when I release the site to the public and (theoretically) get many more users?

    $connection = mysql_connect($mysql_host,$mysql_user,$mysql_password);

    mysql_select_db($mysql_database, $connection);

    // Take the whole user database, and store it in $wholeUserDatabase.
    $wholeUserDatabase = mysql_query("SELECT * FROM myTable")
	    or die(mysql_error());  

    $boolFoundUser = false;

    /* Iterate once for every entry in the database, storing the current entry 
    of the database into a variable $currentEntry, which is an array containing 
    everything related to the one user. */
    while($currentEntry = mysql_fetch_array($wholeUserDatabase)) {

        /* Does the "username" field of the current entry match the one 
        the user tried to log in with? */
        if ($currentEntry['username'] == $_POST['username']) {
	
            /* If it does, break the loop so that the $currentEntry variable 
            will contain the information for the user who is trying to log in,
            which I will later need to check passwords, etc. */
		    $boolFoundUser = true;
		    break;
	    }
    }

    mysql_close($connection);


Thanks for any help. Let me know if I need to rethink this part. I hope this can be helpful to other people.