There should be code to look at and understand, I will not write your code for You. Maybe some one else will work for free for You.
Look at the category module and You should find some examples. Just saying this don´t work, taken out of context does not help much.
using print_r( ... ) helps to see what there is to use.
Jörgen @ Kreativ Fotografi