You have pieces of your query out of order (specifically, where WHERE goes) and you are not doing prepared statements correctly. Note that you put a question mark where each variable goes and then use bind_param to fill in the question marks in order. The first part, "iii"
, means that there are three integers.
$query = $db->prepare("SELECT post_id, title, date, image, LEFT(body, 150) AS body, category
FROM posts
INNER JOIN categories ON categories.category_id=posts.category_id
WHERE posts.category_id=?
order by post_id desc
limit ?, ?");
$query->bind_param("iii", $cat, $start, $per_page);
$query->execute();