The projection operator on to a subspace $E$ spanned by a set of orthogonal states $\{|e_k\rangle\}$ is
$$P_E = \sum_k \frac{|e_k\rangle\langle e_k|}{\langle e_k|e_k\rangle}$$
That was the easy part. But figuring out whether you have a pure state or a mixed state after a measurement is, in some sense, an issue of definitions.
Consider a single quantum system which starts in a pure state $|\psi\rangle$ or $\rho$ (if you prefer density operators). Suppose you measure an observable corresponding to the operator $A$. As a Hermitian operator, $A$ has eigenstates $|a^i_k\rangle$, associated with eigenvalues $a^i$, which form an orthonormal basis. Let's say the result you get is $a^0$; then this particular measurement projects the state of the system on to the subspace $A_0$ spanned by the eigenstates $|a^0_k\rangle$:
$$\begin{align}|\psi\rangle &\to P_{A_0}|\psi\rangle & \rho &\to P_{A_0}\rho P_{A_0}\end{align}$$
Evidently if you're dealing with a single measurement on a single system, assuming you started with a pure state, you can express the post-measurement state as a pure state.
But what if you instead have a large ensemble of systems, each prepared identically and then measured? After the measurement, for each possible result $a^i$, a fraction $p(a^i)$ of the systems will have produced the result $a^i$ and thus will be in the state $P_{A_i}|\psi\rangle$ or $P_{A_i}\rho P_{A_i}$. This is a mixture of systems in different pure states, and thus it corresponds to a mixed state
$$\rho \to \sum_i p(a^i)P_{A_i}\rho P_{A_i}$$
The key difference is that with a single system, you were able to know the result of the measurement, which was the knowledge you needed to "extract" a single pure state from the mixture. But in this case, you can't do that because you have many different result of the measurement.