Find jobs - Wordpress Themes - Submit article - Creative Electronics - Myspace Code

PDA

View Full Version : newbie here


gigamike
Oct 13th 2006, 2:54 am
Hi Guys,

im mikeg from philippines :). Guys i hope you can give me an idea, actually this is easy though im new to php. How i can read this value or parameter in URL

example: www.domain.com/test.php?12

i need to get the value 12 but how? is parsing from right to left is the only option and when i encounter the ? thats the value i need...is there another way?

Thanks a lot,

mikeg

ThomasNederman
Oct 13th 2006, 4:36 am
echo $_SERVER["QUERY_STRING"]; should do it

good luck

penagate
Oct 13th 2006, 5:04 am
Use isset($_GET['12']). It will be set, but with a null value.

ThomasNederman
Oct 13th 2006, 5:26 am
if you use isset() you will have to make a loop if it can be more values like

while $i < 1000000){

if (isset($_GET[$i])){

$value = $i;
}
$i++
}

(the above is a waste of resources on the server)Or easyer why not
www.domain.com/test.php?ID=12
then you can read $_GET['ID'];

penagate
Oct 13th 2006, 6:13 am
Well, it solved the problem that was presented. Not enough info to give a better solution without making assumptions.

gigamike
Oct 13th 2006, 8:15 am
hi guys,

first of all i like to thankyou all for the quick response. Actually i agree to thomas to use this method:

www.domain.com/test.php?referrer=12

unfortunately the client request this method

www.domain.com/test.php?12

I'll try now you suggestions.

Thanks again,

mikeg

mad4
Oct 13th 2006, 8:19 am
I would explain to your client that its impossible and suggest a better way.

gigamike
Oct 13th 2006, 8:22 am
hi,

this works for me $_SERVER["QUERY_STRING"];

thanks again,

mikeg

penagate
Oct 13th 2006, 8:22 am
If you read the suggestions above you'll see it's perfectly possible.