The equilibrium expression is basically a fraction of the activites of the products over the activities of the reactants. These "activities" are are how much reaction potential the substances have. For gases, they depend on pressure, and for aqueous solutions, they depend on concentration.
Because solids and pure liquids have no pressure or concentration, they are not needed in the expression, and are conveniently left out.