As @udiboy said, this question belongs on Chemistry.SE.
The number of valence electrons in an atom is the number of electrons present in the outermost orbit of the atom, NOT adding up the electrons of the last 2 shells. Each orbit can have only a certain number of electrons. That number is equal to $2n^2$, where $n$ is the orbit number. This gives us:
1st orbit $\rightarrow$ 2 electrons
2nd orbit $\rightarrow$ 8 electrons
3rd orbit $\rightarrow$ 18 electrons
... and so on.
Therefore, in the element Sodium(Na), where we have 11 electrons in total, we can distribute them in the following manner:
Orbit 1 $\rightarrow$ 2
Orbit 2 $\rightarrow$ 8
Orbit 3 $\rightarrow$ 1
which adds up to a total of 11.
Since the last orbit is the third orbit, we take the electrons in that orbit as the valence electrons. Thus, the number of valence electrons is 1.
You are getting confused because you've distributed the electrons into the orbitals which exist within the orbits.
The whole concept of orbitals in detail is quite lengthy - I'll try bringing it down.
There are various types of 'subshells' or 'orbitals' which exist within each orbit, the 's' subshell, 'p', 'd', 'f' and so on. They basically represent the most probable areas where the electrons can be found. Each subshell can hold 2 electrons only.
How do we know which orbit can have which subshells?
It's decided by the azimuthal quantum number(l), which has a range of:
$l\in [0,n)$ and $l$ is an Integer. $n$ is the orbit number.
$l=0$ implies the 's' subshell.
$l=1$ implies the 'p' subshell.
$l=2$ implies the 'd' subshell, and so on.
So we can see, for Orbit #1, possible values for $l$ are only '$0$'. So we know that orbit #1 has only the 's' subshell.
Similarly we can find out that:
Orbit #2 has the 's' subshell and the 'p' subshell.
Orbit #3 has 's', 'p' and 'd'.
There is one type of 's' orbital. It is spherical. So an 's' orbital can hold 2 electrons only.
There are three types of 'p' orbitals. They are the same shape (like a dumbell), but are oriented in different directions - along the x, y and z axes. So a 'p' orbital can hold $2$x$3$ = 6 electrons.
There are five types of 'd' orbitals (10 electrons) and seven types of 'f' orbitals (14 electrons).
Fill up the orbitals in the following order (following the red arrows), which is increasing order of energy. Lowest energy fills up first.
1s, 2s, 2p, 3s, 3p, 4s, 3d, 4p, 5s, 4d, 5p, 6s, 4f, 5d, 6p, 7s, 5f, 6d, 7p
So let's take the example of Sulphur.
Total number of electrons are 16. We'll distribute them in the following manner.
$1s^2, 2s^2, 2p^6, 3s^2, 3p^4$, where the superscripts of each orbital represent the number of electrons in it. Now, we have a total of 6 electrons in the last (3rd) orbital. Therefore the valence number is 6.
It is not simply the last 2 numbers while writing the electronic configuration.
For Phosphorous, we have:
$1s^2, 2s^2, 2p^6, 3s^2, 3p^3$, which gives us 5 electrons in outermost (3rd) orbit.
For Lithium (3 electrons), we have:
$1s^2, 2s^1$, which gives us a total of 3. Outermost orbit is the 2nd orbit and total number of electrons in it are just 1. Therefore valency of Lithium is 1.
However, it is much simpler to do it the way I've shown above as with Sodium. Don't need to bring in all the orbitals
For the spin, just remember that you have to fill up the entire orbital with up spin electrons before you start putting the down spin electrons. Don't just alternate up and down.
Let's talk about the 'p' orbital. Each 'type' of the p-orbital must have up-spin electrons before adding the down-spin. So there will be 3 upspin electrons before you start adding the down-spin ones. Also, you can not move on to the next orbital without completely filling the previous one with an EQUAL number of up and down spins.
For Phosphorous; let's say we've filled the 1s, 2s, and 2p orbitals. Now we add one up spin to the 3s, followed by a down-spin. Which leaves us with 3 more electrons to be added to the valence orbit (3rd). It is a 'p'-orbital, which needs to have 3 upspin electrons before any downspin ones can be accomodated. But we have only 3 remaining! So all will be up-spin electrons in the valence orbit. So we'll have a total spin of +3/2.
Hope I didn't complicate too much, but I've actually tried to make it AS short as possible. I've still left out quite a bit.