Don't use $$. If you use \begin{equation} and \end{equation} then you'll have numbers automatically generated.
If you want several lines in a row with numbers, you can use the align environment like so:
\begin{align}
\cos^2 \theta + \sin^2 \theta &= 1 \\
\sin\left(\theta + \frac{\pi}{2}\right) &= \cos \theta
\end{align}
This requires the amsmath package.
You may recognise this code from my answer to your other question.
Here is some sample code that shows these basics:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Here is some text.
\begin{equation}
e^{i\pi}+1=0 \tag{Euler}\label{eq:euler}
\end{equation}
Some more text.
\begin{align}
\cos^2 \theta + \sin^2 \theta &= 1 \\
\sin\left(\theta + \frac{\pi}{2}\right) &= \cos \theta \label{eq:trig}
\end{align}
I can refer to the line I have labelled like so: \ref{eq:trig}.
Or if I'd rather have the number enclosed in parentheses: \eqref{eq:trig}.
Also, if I refer to an equation I have ``tagged'' then I get the text of the tag: \eqref{eq:euler}.
\end{document}
Required reading: