Page 1 of 1

PHP Help

Posted: Fri Feb 21, 2003 7:27 pm
by Simon18711
Hello can any1 tell me wat the code is so i can make a link look like this?! http://yoursite.com/news.php?id=1 i want the ?id=1 onto the end of my page url! and to bring up the data from the DB! i hope u can help me :)

Thanks!

Posted: Fri Feb 21, 2003 8:05 pm
by volka
passing parameters this way is called GET-method.
In newer versions of php (see also: http://forums.devnetwork.net/viewtopic.php?t=511) the script can access those values via the superglobal array $_GET.
In your example it would be

Code: Select all

$_GET['id'] == '1' // --> TRUE

see also:
http://www.php.net/manual/en/language.v ... ternal.php
http://www.php.net/manual/en/function.urlencode.php
http://www.php.net/manual/en/reserved.variables.php
http://www.php.net/manual/en/language.v ... .scope.php

Posted: Fri Feb 21, 2003 9:35 pm
by fractalvibes
Or you can always build the link on the fly in php

echo "<a href='mypage.php?ID=" . $MyVar . "'>";
as needed....

PhilJ