#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Canada
    Posts
    35
    Rep Power
    15
    Hi all,
    I wrote this script to retrieve datas from SQL. If there are more than $limit datas, the results are displayed on several pages according to the number of datas retrieved.
    My question: how can I disable the link for the current page?
    For example, if there are 3 pages of results and I am on page 1, I would like to have page 1, page 2, page 3 listed in the correct order, but page 1 would be disabled (not under A HREF)
    Thanks all,

    my script:

    $limit=5;

    IF(empty($page)) /* first query*/
    {$page=1;}

    $start=($page-1)*$limit;
    $first=$start+1;
    $last=$start + $limit;
    IF ($last>$number)
    {$last=$number;}

    PRINT "<CENTER><P><font face=Arial, Helvetica, sans-serif size=2>Jobs <B>$first </B> to <B>$last</B>:</font></P></CENTER>";
    .
    .
    .
    .
    .
    /* how many pages? */
    $nbpages=ceil($number /$limit);

    PRINT"<BR></BR>";
    PRINT"<BR></BR>";

    PRINT"<p align=center><font face=Arial, Helvetica, sans-serif size=1>";


    for($a = 1;$a <= $nbpages;$a ++)
    {
    PRINT "<a href='$PHP_SELF?location=$location&position=$position&field=$field&page=$a&number=$number'>Page $a</a> n n";}
    PRINT"</font></p>";
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    for($a = 1;$a <= $nbpages;$a ++)
    {
    PRINT "<a href='$PHP_SELF?location=$location&position=$position&field=$field&page=$a&number=$number'>Page $a</a> n n";}
    PRINT"</font></p>";



    Give one if condition in the for loop


    it should be something like:


    for($a = 1;$a <= $nbpages;$a ++)
    {
    if ($page==$a){
    //current page

    echo "Page ".$a;

    }else{
    PRINT "<a href='$PHP_SELF?location=$location&position=$position&field=$field&page=$a&number=$number'>Page $a</a> n n";}
    PRINT"</font></p>";
    }
    }


    i hope that will work for you..

    Good Luck!!!

    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Canada
    Posts
    35
    Rep Power
    15
    Thanks a lot!
    I was trying with if ($page=$a), and of course it did not work...such a stupid error
    anyways, thanks a lot because everything works beautifully now

Similar Threads

  1. Help with Java Script
    By AShain in forum HTML Programming
    Replies: 1
    Last Post: February 17th, 2004, 04:29 AM
  2. closes a page when clicking a link
    By schnyderite in forum HTML Programming
    Replies: 2
    Last Post: February 17th, 2004, 02:52 AM
  3. Javascript links - 'error on page'
    By George Little in forum JavaScript Development
    Replies: 0
    Last Post: February 6th, 2004, 04:25 PM
  4. Replies: 1
    Last Post: February 5th, 2004, 10:33 PM
  5. Replies: 5
    Last Post: January 23rd, 2004, 11:22 AM

IMN logo majestic logo threadwatch logo seochat tools logo