PHP Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Simon18711
Forum Newbie
Posts: 4
Joined: Fri Feb 21, 2003 7:27 pm

PHP Help

Post 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!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

Or you can always build the link on the fly in php

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

PhilJ
Post Reply