File handling issue

i am outputting a list of folders which i have done. But when you click on the folder i want it to display its contents (mostly pdf’s, jpgs), how would i do this?