mysql_select_db takes only two parameters. You're passing 3.
bool mysql_select_db (string database_name [, resource link_identifier])
You should be calling mysql_select_db($db, $link);
Note that you don't make a query with select_db! You just specify which databse you're working off of. You want to do this:
mysql_select_db($db, $link);
$nav_query = "SELECT * FROM $table1";
$result = mysql_query($sql);
while($nav_row = mysql_fetch_array($result)) {
...
}