title: pagination current page color
body: <p>below is my php pagination code. I want to add color to my current page number in pagination layout. Someone please look at the code below as i don't know much about php and help me writing current page number color code. Everything is working very well with this code except it's not highlighting the current page number. I have added current page color, then i realized it has something to do with pagination code.</p>
  
  <pre><code>public function getBasicPagination($total_pages, $page, $limit, $targetpage) {
    $adjacents = 3;
    if ($page == 0) {
      $page = 1;
    }
    $prev = $page - 1;
    $next = $page + 1;
    $lastpage = ceil($total_pages / $limit);
    $lpm1 = $lastpage - 1;
    $pagination = "";
    if (1 &lt; $lastpage) {
      if (1 &lt; $page) {
        $pagination. = " &lt;a href=\"{$targetpage}{$prev}\"&gt;&amp;laquo;&lt;/a&gt; ";
      }
      else {
        $pagination. = " ";
      }
      if ($lastpage &lt; 7 + $adjacents * 2) {
        $counter = 1;
        while ($counter &lt;= $lastpage) {
          if ($counter == $page) {
            $pagination. = " &lt;a href=\"{$targetpage}{$counter}\"&gt;{$counter}&lt;/a&gt; ";
          }
          else {
            $pagination. = " &lt;a href=\"{$targetpage}{$counter}\"&gt;{$counter}&lt;/a&gt; ";
          }
          if ($counter &lt; $lastpage) {
            $pagination. = " ";
          }
          ++$counter;
        }
      }
      else if (5 + $adjacents * 2 &lt; $lastpage) {
        if ($page &lt; 1 + $adjacents * 2) {
          $counter = 1;
          while ($counter &lt; 4 + $adjacents * 2) {
            if ($counter == $page) {
              $pagination. = " &lt;a href=\"{$targetpage}{$counter}\"&gt;{$counter}&lt;/a&gt; ";
            }
            else {
              $pagination. = " &lt;a href=\"{$targetpage}{$counter}\"&gt;{$counter}&lt;/a&gt; ";
            }
            if ($counter &lt; 3 + $adjacents * 2) {
              $pagination. = " ";
            }
            ++$counter;
          }
          $pagination. = " ... ";
          $pagination. = " &lt;a href=\"{$targetpage}{$lpm1}\"&gt;{$lpm1}&lt;/a&gt; ";
          $pagination. = " &lt;a href=\"{$targetpage}{$lastpage}\"&gt;{$lastpage}&lt;/a&gt; ";
        }
        else if ($page &lt; $lastpage - $adjacents * 2 &amp;&amp; $adjacents * 2 &lt; $page) {
          $pagination. = " &lt;a href=\"{$targetpage}1\"&gt;1&lt;/a &gt; ";
          $pagination. = " &lt;a href=\"{$targetpage}2\"&gt;2&lt;/a&gt; ";
          $pagination. = " ... ";
          $counter = $page - $adjacents;
          while ($counter &lt;= $page + $adjacents) {
            if ($counter == $page) {
              $pagination. = " &lt;a href=\"{$targetpage}{$counter}\"&gt;{$counter}&lt;/a&gt; ";
            }
            else {
              $pagination. = " &lt;a href=\"{$targetpage}{$counter}\"&gt;{$counter}&lt;/a&gt; ";
            }
            if ($counter &lt; $page + $adjacents) {
              $pagination. = " ";
            }
            ++$counter;
          }
          $pagination. = " ... ";
          $pagination. = " &lt;a href=\"{$targetpage}{$lpm1}\"&gt;{$lpm1}&lt;/a&gt; ";
          $pagination. = " &lt;a href=\"{$targetpage}{$lastpage}\"&gt;{$lastpage}&lt;/a&gt; ";
        }
        else {
          $pagination. = " &lt;a href=\"{$targetpage}1\"&gt;1&lt;/a&gt; ";
          $pagination. = " &lt;a href=\"{$targetpage}2\"&gt;2&lt;/a&gt; ";
          $pagination. = " ... ";
          $counter = $lastpage - (2 + $adjacents * 2);
          while ($counter &lt;= $lastpage) {
            if ($counter == $page) {
              $pagination. = " &lt;a href=\"{$targetpage}{$counter}\"&gt;{$counter}&lt;/a&gt; ";
            }
            else {
              $pagination. = " &lt;a href=\"{$targetpage}{$counter}\"&gt;{$counter}&lt;/a&gt; ";
            }
            if ($counter &lt; $lastpage) {
              $pagination. = " ";
            }
            ++$counter;
          }
        }
      }
      if ($page &lt; $counter - 1) {
        $pagination. = " &lt;a href=\"{$targetpage}{$next}\"&gt;&amp;raquo;&lt;/a&gt; ";
      }
      else {
        $pagination. = " ";
      }
    }
    if (empty($pagination)) {
      $pagination = " &lt;a href=\"{$targetpage}1\"&gt;1&lt;/a&gt; ";
    }
    return $pagination;
  }
  </code></pre>