How to change url id or parameter when i clicked previous and next button?

I have three templates, then i have to display those templates randomly when I click previous or next button. And also on those templates I will display those articles (with title and body) .By the way I am using Php and javascript. I have already those articles in the database.
So my problem is when i click the next or previous button, I couldn’t change the url id (parameter). Someone can help or suggest me? Thanks all