Prove that every element of $\mathbb{Z}_n$ is either a unit or a zero divisor. So here is what I have so far:
$[a]_n$ is a unit iff $(a,n) = 1$.
Otherwise, $(a,n) = d$ with $d \neq 1$. Let $n = dq$, then $[q]_n \neq [0]_n$, where $1\leq q<n$.
So this is where I'm stuck.  Where do I go from here?
The book does a proof of this but I don't quite understand the way they explain it.
The book I'm using is Abstract Algebra by John A. Beachy and William D. Blair.
 A: Let $a=bd$. Then $a\cdot\frac{n}{d}=(bd)\cdot \frac{n}{d}=bn$. 
Since $d\gt 1$, we have $[n/d]_n\ne [0]_n$. But since $n$ divides $a\cdot \frac{n}{d}$, we have $[a]_n[n/d]_n=[0]_n$.  
A: Consider $\phi_k:\mathbb{Z}_n \to \mathbb{Z}_n$ given by $[x]_n \mapsto [k]_n[x]_n$.
If $\phi_k$ is not one-to-one, then there exist two distinct residue classes $[a]_n$ and $[b]_n$ such that 
$[k]_n[a]_n = [k]_n [b]_n$. Then $[k]_n[a]_n-[k]_n[b]_n = [0]_n$. Because $ka-kb=k(a-b)$, this implies 
$[k]_n [a-b]_n = [0]_n$. Since $[a]_n$ and $[b]_n$ were assumed distinct, $[a-b]_n \neq [0]_n$, and so $[k]_n$ is a divisor of zero.
Otherwise, the map $\phi_k$ is one-to-one. Since $\mathbb{Z}_n$ contains only $n$ elements, $\phi_k$ must also be onto. Thus there must exist some residue class $[a]_n$ for which 
$\phi_k\left([a]_n\right) = [1]_n$, or in other words for which
 $[k]_n [a]_n = [1]_n$. Thus $[k]_n$ is a unit.
This argument works for every $k$. We see then that every residue class is either a unit or a zero divisor.
This argument doesn't tell us which residues are units, but it has the advantage of being readily generalized to any finite ring.
