how to get URL variable

i have a problem. i am declaring one variable id  in one site and want to retrive  that id in another site. how can i?
like http://localhost/New%20Site/jeans.php?=1

i want one(1) after the ?= sign.

how to get this variable 1?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think you need to make yourself slightly clearer in the question.

If you are doing what I think you are trying to do, and just pass arguments you can call the site like


Then on the other site you can do something like


$id = $_GET['id'];


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial



    echo $_SERVER['QUERY_STRING'];

heres a full example of how to pass a variable from one page to the next, it should help you understand how it works better:

file 1 (1.php in example)

$var = 5;
echo "<a href=\"2.php?variable=$var\">link</a>";

file 2 (2.php in example)

$newvar = $_GET['variable'];
echo $newvar;

      $parts = split ("=", $_SERVER['QUERY_STRING'];);
       $total = count($parts) - 1;
       $fieldyouwant = $parts[$total];

$fieldyouwant will contain that '1' that you needed.  It will not work if there is more than one field being passed.  Then you will have to do $parts[$total-whatever] as well to get the other variables.  It basically splits it apart between = signs.  I cannot remember if a '\' is needed before the '=' sign.  

hope that helps,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.