Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    74
    Thanks
    4
    Thanked 0 Times in 0 Posts

    get and use curent page URL

    Hy
    I wanna use the curent URL in pagination links.
    Now I get : http://www.domain.com/title.php?page=2 (3,4,5...999) and I need to be something like this: http://www.domain.com/title.php?type...=Submit?page=2 (3,4,5...999)

    Or how can I transform the current URL in simple http://www.domain.com/title.php.

    I mention the URL is from a search query.

    Here is my code


    PHP Code:
    <?php
    function curPageURL() {
     
    $pageURL 'http';
     if (
    $_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
     
    $pageURL .= "://";
     if (
    $_SERVER["SERVER_PORT"] != "80") {
      
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
     } else {
      
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }
     return 
    $pageURL;
    }
    ?>



      $curPageURL = curPageURL();


    ///this is the pagination code
        if($pages >= 1 && $page <= $pages){
                    for ($x=1;  $x<=$pages; $x++){
                         $pagination .= ($x == $page) ? '<strong>' . $x . '</strong> ' : '<a href="?page=' .$x. '"> ' . $x . '</a> ';
                        }
                    
            }

    and if I use <a href="$curPageURL?page=' .$x. '"> I get something like this www.domain.com/$curPageURL?page=2 (3,4,5...999)


    thank you
    Last edited by _user; 04-25-2012 at 08:11 PM.


 

Posting Permissions

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