In case you don't know how looting works in Clash of Clans and how important it is to max out your defenses before upgrading your Town Hall, check out Lt. Nixon's guide to looting:
Part 1 (old update, includes important figures)
Part 2 (latest update, important figures not included)
For those who don't have the time to watch the videos, this is a very brief summary on looting percentages:
Gold/elixir storages : Can only steal up to a maximum of 25% of the available loot
Mines/collector: Can only steal up a maximum of to 50% of available loot
Dark elixir storages : Can only steal up to a maximum of 5% of the available loot
Dark elixir drills: Can only steal up a maximum of to 75% of available loot
Consider the sum of all this available loot as 100%.
Now, amount of loot available for stealing is based on the difference in Town Hall levels..
2 levels below: 50%
1 level below: 90%
Same level: 100%
1 level above: 110%
2 levels above: 150%
Example: Your Town Hall is level 7. You are raiding a level 7 Town Hall.
He has 100,000 gold and 100,000 elixir in the storages. He also has 1,000 gold and 1,000 elixir in the mines and pumps.
The maximum total available gold for looting in the storage is:
100,000 gold x 25% = 25,000 gold
The maximum total available gold for looting in the mines is:
1,000 gold x 50% = 500 gold
The total maximum gold for looting is:
25,000 + 500 = 25,500 gold.
This is considered to be 100% of available loot. Since you are Town Hall 7 and he is Town Hall 7, you can loot up to 100% of the gold, ie. 25,500 gold. Likewise for elixir and dark elixir.
However, if he was Town Hall 8, you would be able to loot a maximum of 110% of 25,500 gold (28,050 gold). (I'm sure Supercell have algorithms to mathematically determine the additional amounts from the storages and mines so we don't have to worry about that.) Likewise for Town Halls below yours.