Prove that there exists an $x' \in [a,b]$ such that $f(x') = \frac{\int^b_a fg}{\int^b_a g}$ for the given conditions.
Here's a hint:
Define $$I(x)=\int_{a}^xf(t)g(t)dt-\int_{a}^b f(t)g(t)dt \frac{\int_{a}^xg(t)dt}{\int_{a}^bg(t)dt}$$
Note that $I(a)=I(b)=0$. By Rolle's theorem there exists $\xi\in (a,b)$ such that $I'(\xi)=0$. Can you finish from here?