There are a lot of examples in the manual. And, for this situation, there is example, how to do, what you need now.
BTW. I preffer to point to manual page, because if you read it, you will not ask such questions in the feature. Otherwise (if I'll post code fragment here) you will simple insert it into your page, and will ask the same question next time...