there are a number of online tools that you can use to generate the mod_rewrite code for you.
for example this webmaster toolkit page:
or another one here:
you can find more resources through Google by using the following search terms:
mod_rewrite cheat sheet
mod_rewrite query string