This[
^] NeHe article (among other things) shows you how to render to a texture. The basic procedure is to set the viewport to the size of the texture then render whatever you need, and finally to copy your screen buffer to the texture using glCopyTexImage2D.
If you need to update the texture every frame you'd be better off avoiding the copy to texture and rendering straight onto the texture using FBOs (Frame Buffer Objects) which is demonstrated
Here[
^] but it's a little more complicated.