Hi Happy,
You should follow weedpackets advice. Although he links himself to mind-numbing substances, he is actually well-versed in php programming, and the authority on the board.
Give it a crack with the links that he gave you, and show us how you go. (It is easy to give you a piece of code, but it will not help you in the long run).
Give it a stab, and let us know where you are stuck.
J.