Sign in to follow this  

[web] Help - PHP

Recommended Posts

I'm trying to make links dynamically where when you click them they reload the page passing an argument. Ala:
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>");

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.

Share this post

Link to post
Share on other sites
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


Will contain it already decoded.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this