Query String Syntax

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
Hawaii02
Forum Newbie
Posts: 4
Joined: Tue May 29, 2007 3:53 am

Query String Syntax

Post 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.
Mohit_Prog
Forum Commoner
Posts: 26
Joined: Mon Apr 23, 2007 6:10 am

Post 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> .
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
... and the values will be in

Code: Select all

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

djot
-
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
Post Reply