Page 1 of 1

Query String Syntax

Posted: Wed May 30, 2007 2:36 am
by Hawaii02
I was wondering if someone could give me an example of how I could attach a variable to a hyperlink in PHP so that the value of the variable is carried over to the next page and used on that page. I've done it in ASP where you have your link followed by a ?variable=value then use the query string function to get it, but never done this in PHP and not sure of the syntax.

thanks.

Posted: Wed May 30, 2007 4:35 am
by Mohit_Prog
same synytax you can use in PHP also.
It is not language dependant.

<a href="mypage.php?var1=1&var2='name'">Test</a> .

Posted: Wed May 30, 2007 4:39 am
by djot
-
... and the values will be in

Code: Select all

<?php
var_dump $_GET['var1'];
var_dump $_GET['var2'];
?>
then.

djot
-

Posted: Wed May 30, 2007 8:38 am
by CoderGoblin
You may also want to look at php sessions as a way to store variables rather than passing them all over the place, especially in a complex environment with many variables needing to be passed.