I want to create a link to a specific forum post. To do this, I need to calculate which page within the thread the post is on since I am using pagination. How can I calculate which page a message will be on based on the number of results per page?
I use the following query to find the total number of messages in the thread:
SELECT
COUNT(message_id) AS total_messages, thread_id
FROM forum_messages
WHERE thread_id = 1