www.webdeveloper.com
Results 1 to 3 of 3

Thread: using parameter passing and anchor

  1. #1
    Join Date
    Dec 2006
    Posts
    5

    Smile using parameter passing and anchor

    Hello everyone,

    I am very new to PHP and I ran into a problem and I don't know how to solve... I want to pass in the anchor id and the parameter value to the next page through the URL, but I can't figure out the way to do it, and I am not sure if it is even doable


    firstPage.php:
    Code:
    ...
    <a href="secondPage.php#menu?name=bob">link</a>
    ...

    secondPage.php:
    Code:
    ...
    <div id="menu">...</div>
    ...
    <?php print $_GET['name']; ?>
    the second page doesn't receive the $_GET['name'] variable, if i print the value, it prints nothing.
    I am thinking the reason may be the anchor tag, and php interpreter interprets everything after the # is the id of the anchor. Is there anyway to escape the anchor in front of the '?'? Thanks.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,926
    The anchor should come last, after the URL query string:
    HTML Code:
    <a href="secondPage.php?name=bob#menu">link</a>
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Dec 2006
    Posts
    5
    thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles