Ok so if the player#1 holds (A)(A) and player#2 holds a (3)(6) and the board has (K)(7)(3)(7)(6). Who wins?
Poker hands have EXACTLY FIVE CARDS: no more, no less. Player 1's best five-card hand is A-A-7-7-K, two pair, aces over sevens. Player 2's best five-card hand is 7-7-6-6-K, two pair, sevens and sixes. Player 1 wins. There's no such thing as "three pair", because that would require six cards, and only five cards count.
You need to look at the best five cards you can get from the seven cards in front of you(2 in your hands) and the 5 cards of the board.
Next you need to understand the rank of poker hands.
In your example, Player 1 wins since his hand will be AA77K and other player's hand would be 7766K.
Although, in this particular example it is not possible for player 2 to have flush, it is worth mentioning that the suit of the cards plays an important role, since player 2 here could have won, if he has 5 cards of the same suit (Flush ranks higher than two pair).