Results 1 to 1 of 1

Thread: highlight current page in pagination

  1. #1
    Join Date
    Jun 2008
    Posts
    121
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default highlight current page in pagination

    hi all

    taking an example of pagination that has applied on this forum for displaying threads.

    i want to hightlight the page number in my pagination.

    at present what i m getting is that if there are 4 pages. means page 1,2,3,4. Then all numbers are having black background.
    when i click page number 2 then, page number 1 becomes without background and changes to default link colour of browser not my stylesheet. when i click page number 3, then page number 1,2, will become without background with default browser link colour not my stylesheet link color.

    The page numbers are not even displaying hover effect on rollover. what is my script doing wrong.


    this is css
    Code:
    <style type="text/css">
    a.paging:link {background-color: #FFCC00; text-decoration: none; color:#FFFFFF}
    a.paging:visited {background-color: black; text-decoration: none;  color:#FFFFFF}
    a.paging:active {background-color: #FFCC00; text-decoration: none;  color:#FFFFFF}
    a.paging:hover {background-color: #FFCC00; font-weight:bold; color:#FFFFFF}
    </style>
    <style type="text/css">
    a.pagingCurrent:link {background: #FF0000; text-decoration: none; color:#FFFFFF}
    a.pagingCurrent:visited {background: black; text-decoration: none;  color:#FFFFFF}
    a.pagingCurrent:active {background: #FF0000; text-decoration: none;  color:#FFFFFF}
    a.pagingCurrent:hover {background: #FF0000; font-weight:bold; color:#FFFFFF}
    </style>
    here is code of php loop which displays page numbers.
    PHP Code:
    <?php
    $dealer_id
    =$_REQUEST['dealer_id'];
    $category_id=$_REQUEST['category_id'];
     
    $sql "SELECT * FROM product_table where dealer_id=$dealer_id";
        
    $q mysql_query($sql);
        
    $total_records mysql_num_rows($q);
        
    $records_per_page 1;
        
    $total_pages ceil($total_records $records_per_page);
        
    $page intval($_GET['page']);
        if (
    $page || $page $total_pages) {
            
    $page 1;
        }
        
    $offset = ($page 1) * $records_per_page;
       
       
    $sql "SELECT * FROM product_table where dealer_id=$dealer_id LIMIT $offset$records_per_page";
    $result=mysql_query($sql);
    while(
    $row mysql_fetch_array($result))
        {
         
    $desc substr($row['detail_description'], 0250);
           echo 
    "<td valign=top class='des' width=250>"$desc "</td>";
           echo 
    "</tr>";
            echo 
    "<tr>";
         }
    echo 
    "No. of Pages";
    for (
    $i 1$i <= $total_pages$i++) 
    {
            if (
    $i == $page) {
                
    $class 'pagingCurrent';
                
    $prepend 'Page';

    else

    $class 'paging';
    $prepend 'Page';
    }
    echo 
    "<a href='products-".$dealer_id."-"$category_id"-"$i".html' class='" $class "'>" $prepend$i "</a>\n";
            unset(
    $class$prepend);
    }  
    ?>
    vineet
    Last edited by vineet; 12-17-2008 at 03:22 PM. Reason: code

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •