I made pagination with PHP and jQuery for topic+entry project
Lets say a topic has five pages. I made a refer system if my user write “@5” in 10th post and another user clicked @5, page slide up to 5th comment. But I don’t know how to refer to if user write “@5” in 20th post. page may not find that div because 5th post is at 1st page,
and my pagination per page limit is 15 and I have 5 pages.
What am I supposed to do? Maybe I can calculate fifth post is in the first page and make a chain events in jQuery: go to first page and slide to fifth post etc I don’t know that is.
You can use the same method than stackoverflow uses to link answsers: you provide in the url the id of the page, and the id of the specific answer (or comment, in your case). And your php script, when it sees this format of url, thansforms the url with an html anchor.
For example: http://yoursite/question_id/comment_id is redirected to site/question_id#comment_id
You can test it on this very answer by clicking this link: https://stackoverflow.com/a/10027770/311744.
This url provides enough information so that the server redirects to the correct page (the current page in this case), with the anchor to this answer (#10027770).
Then you can handle manually the special case where the comment is on the current page and prevent the reload of the same page with javascript (but I woudn’t bother, and SO doesn’t either)
Edit: What I understand is that you want to be able to click on “@5” written on a user comment, and this comment should somehow be displayed.
At this point you have two solutions: