Hey,
I want to pass multiple variables with the get method. The names of the variables are the same.
It works with one variable:
url = http://www.mysite.com/testing.html?name=jon
In my code I write : $variabele = $_GET["name"];
But now!!!!!:
http://www.mysite.com/testing.html?name=jon&name=mike
How can I put the names jon and mike (or even more names) in variables?
If I use: $name = $_GET["name"] , I only get the last name.
I also could write my program that I'll send this:
http://www.mysite.com/testing.html?name1=jon&name2=mike&...
But than I need to know how many variables I'm receiving. If I write:
$variable5 = $_GET["name5"]
and there's no name5, I get a warning. How can I know how many variables there are?
Can someone help me with this?
Thanx
Dirk
passing variables
Moderator: General Moderators
try php will handle parameters paramName[]=value like php-codeso the value will be appended to the array $paramName (or $_GET['paramName']).
For links you have to urlencode [ and ] which results in
http://www.mysite.com/testing.html?name ... 5B%5D=mike&...
Code: Select all
<html>
<body>
<pre><?php print_r($_GET); ?></pre>
<form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="name[]" />
<input type="text" name="name[]" />
<input type="submit" />
</form>
</body>
</html>Code: Select all
<?php $paramName[]='value'; ?>For links you have to urlencode [ and ] which results in
http://www.mysite.com/testing.html?name ... 5B%5D=mike&...