Dynamic Variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deepaks85
    New Member
    • Aug 2006
    • 114

    #1

    Dynamic Variables

    Dear Sir,

    In PHP script many hyperlinks I have seen the link :

    For example:

    <a href="main.php?show=51&vAED=A &cat=letter">Add Letter </u></a>.</div></td>


    If we write <a href="main.php" > then I can understand that the link goes to main.php file.

    BUT

    when we write '?show=51&AED=A &cat=letter' then I can not understand that why we put this '?' in href properties. [I have marked it bold in above example which I want to understand].

    Plese explain to me.

    Thanks
    Deepak Saxena
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    When you want to pass parameters to script that you want to be called (in this case index.php), you append the parameter keys and values to the called script name, prefixed with a question mark. E.g. when you want to link to program XYZ.PHP and you want to pass parameter key PARM with value ABC, you would code it like:
    [HTML]href=“XYZ.PHP?P ARM=ABC“[/HTML]
    In XYZ.PHP you can now extract the passed value ABC from entry PARM in the $_GET array.

    When you want to pass more parameters to the called script, let´s say you also want to pass NUMBER=123 you must separate the various parameter key=value strings with an amsersand &. So adding the extra becomes
    [HTML]href=“XYZ.PHP?P ARM=ABC&NUMBER= 123“ [/HTML]

    In XYZ.PHP you can now extract both values ABC and 123 from entries PARM and NUMBER, both in the $_GET array.

    I strongly advise you to follow a few HTML and maybe PHP tutorial, because this is all really basic stuff. Good luck!

    Ronald :cool:

    Comment

    Working...