for($rankIndex = 1; $rankIndex <= 5; $rankIndex++) {
echo($ranks[$rankIndex] . "<br>");
while($memberNames[$rankIndex][$index] != "" && $memberNames[$rankIndex][$index] != "_DEFAULT") {
$name = $memberNames[$rankIndex][$index];
echo("<a href=$memberPage?profile=$name>$name</a><br>");
$index++;
}
echo("<br>");
}
[web] Help - PHP
I'm trying to make links dynamically where when you click them they reload the page passing an argument. Ala:
The problem is $memberNames[$rankIndex][$index] has more than one word. Like "Joe Schmoe" and it is only setting ?profile to the first part.. ala ?profile=Joe instead of ?profile=Joe%20Schmoe.
How do I fix that? I kinda know whats wrong and have tried doing ?profile=\"$name\" but that just does ?profile="Joe.
The $name as the link text works just fine, displaying the whole string.
Any help is appreciated.
You'll have to urlencode the string for the link, swapping spaces for the %20 equivalent otherwise this sort of behaviour is expected. Likewise, on the page that takes the string as GET input, you'll need to call urldecode
You have to urlencode stuff in query strings in links.
But you don't have to urldecode it when it comes back in, it is automatically decoded by PHP, so
$_GET['profile']
Will contain it already decoded.
Mark
But you don't have to urldecode it when it comes back in, it is automatically decoded by PHP, so
$_GET['profile']
Will contain it already decoded.
Mark
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement