1) String not quoted:
$mydatabase = 'nistarr';
2) You're closing the connection before doing the query. That shouldn't be done until you're through with the database.
mysql_close($link);
3) Extra closing brace before the "while":
}
By the way, I was getting error messages shown when I ran this. You might have error message display turned off in your php.ini file. In that case, the errors should have shown up in your server error log.
It's also helpful to raise the error reporting level when debugging:
error_reporting(E_ALL);