1. You know from equation 2:
$\displaystyle \displaystyle{y-y_0=-\frac1m(x-x_0)~\implies~(y-y_0)^2=\frac1{m^2}(x-x_0)^2}$
2. $\displaystyle \displaystyle{|\overline{PQ}|=\sqrt{(x-x_0)^2+(y-y_0)^2}}$
Replace $\displaystyle \displaystyle{(y-y_0)^2}$ by the term of #1:
$\displaystyle \displaystyle{|\overline{PQ}|=\sqrt{(x-x_0)^2+\frac1{m^2}(x-x_0)^2}}$
$\displaystyle \displaystyle{|\overline{PQ}|=\sqrt{\frac{m^2}{m^2 } (x-x_0)^2+\frac1{m^2}(x-x_0)^2}}$
Factor out $\displaystyle \displaystyle{(x-x_0)^2}$
$\displaystyle \displaystyle{|\overline{PQ}|=\sqrt{\frac{m^2-1}{m^2} (x-x_0)^2}}$