passing variables from current url in new href url in HTML code.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cosmic Surfer
    New Member
    • May 2010
    • 2

    #1

    passing variables from current url in new href url in HTML code.

    I would like to use code to collect variables from a current url like:

    http://www.example.com/trythis.php?v...iable&?num=123

    I can not find a proper way to get the variable num=123 into an url located in the body of my HTML. For example

    <a href="http://www.example.com/promo_board.php ?tid=209&?num=(the desired num variable here)">
    Last edited by Niheel; May 12 '10, 07:44 PM. Reason: removed irrelevant question details
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    use $_GET.

    Code:
    <?php echo $_GET['num']; ?>



    Dan

    Comment

    • Cosmic Surfer
      New Member
      • May 2010
      • 2

      #3
      Thanks Dan,

      tried it, but don't know how to get the fetched value in the new link address.
      How do I get the value in there?

      When I use echo I see that it presents the right value as expected, but when clicking the new link, it added just the variable name, instead of the value!
      I am directed to a website with url:



      Were it misses the 123 value?

      Comment

      • zorgi
        Recognized Expert Contributor
        • Mar 2008
        • 431

        #4
        Originally posted by Cosmic Surfer
        Thanks Dan,

        tried it, but don't know how to get the fetched value in the new link address.
        How do I get the value in there?

        When I use echo I see that it presents the right value as expected, but when clicking the new link, it added just the variable name, instead of the value!
        I am directed to a website with url:



        Were it misses the 123 value?
        Is there some code? How do you generate those links?

        Comment

        • dlite922
          Recognized Expert Top Contributor
          • Dec 2007
          • 1586

          #5
          You only need one question mark, where you have two:

          ?var=variable&? num=123

          should be

          ?var=variable&n um=123

          get rid of the second one. The reason why It didn't show (i bet) is the 123 value was stored in $_GET['?num'] instead of $_GET['num'];





          Dan

          Comment

          Working...