I have a comment system with pagination, 10 per page. I want to make permalinks to the comments. I'd like to be able to have the script figure out what page the comment is on without having to specify the page number and without excessively large queries or processing. So, for example, a link to a comment on page 5 would open the browser on comment page 5 and #scrolled to the comment (as opposed to showing the comment on it's own page).
I had thought to use 2 mysql queries, one SELECT all CommentId and then php array_search
to find the position in the result and from that I could calculate what page it would be on. A 2nd query would get the page of comments required. This seems quite inefficient though especially if there are a lot of comments Ids to pull.
Could anyone suggest a simpler or more efficient way?