fixing sql in post view