Connecting Tech Pros Worldwide Forums | Help | Site Map

Dynamic Variables

Member
 
Join Date: Aug 2006
Posts: 110
#1: Oct 17 '06
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's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Oct 18 '06

re: Dynamic Variables


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?PARM=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?PARM=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:
Reply