this code below prints a pagination so ex
[first 1 2 3 4 5 ... last]
php code works fine and link do change in url. but the problem is that i want to set up a active class.
so if user click on page 2 than it should be set to active class.

///////////////////////////////
    /****** pagination **********/
    ///////////////////////////////
    if($pages >= 1 && $page <= $pages)
    {
        echo"<div id='container'>";
            echo"<div class='pagination dark'>";
                echo'<a href="?page=1" class="page dark">first</a>';
                for($x=2; $x< $pages; $x++) //botom pages link
                {
                  echo'<a href="?page='.$x.'" class="page dark">'. $x .'</a> '; 
                }
                echo'<a href="?page='. $x .'" class="page dark">last</a>';
            echo"</div>";
        echo"</div>";
    }

i was think if user click on link 2 than in css i can do some thing lik this:

.active_class
{
  //...
}

a:active
{
  //add .active_class to this link
}

Maybe a jquery click event triggers and .addclass? Can you be specific as to how you want it to be done?