Compressing a folder (tar) without its containing directory in the folder name

The easiest way to do that is to cd to the directory first:

cd /path/to/containing/folder && tar -zcvf tarfile.tar.gz foldername_tocompress

So that the (containing) folder's directory becomes the root directory of your compressed file.

A bit more advanced is using the -C option:

tar -zcvf tarfile.tar.gz -C /path/to/foldername_tocompress .

This creates a tar.gz file in the current (working) directory, containing all files/folders inside foldername_tocompress (mind the dot, saying all files/folders should be included).