Web Analytics Made Easy -
StatCounter Sending a name instead of id in a function - CodingForum

Announcement

Collapse
No announcement yet.

Sending a name instead of id in a function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resolved Sending a name instead of id in a function

    Is it possible to send a name of an item through a GET method, to a function, instead of the classic id?

    The link is like this

    PHP Code:
    equipinv.php?x=burn:Blunt Dagger 
    Is it possible to click a link and have it find that name in a query and display it?
    It'd be the same as $id which would look like:

    PHP Code:
    equipinv.php?x=burn:3912 
    But I need it to show the name, and the name has spaces.
    Last edited by myfayt; Sep 1, 2011, 11:03 AM.
    Been a sign maker for 8 years. My business:
    American Made Signs

  • #2
    Sure, its simple really. You could use something like this when a user clicks on an item:
    Code:
    equipinv.php?x=burn:Blunt_Dagger
    Then, use the get method to retrieve the variable:
    PHP Code:
    $inv $_GET["x"]; 
    Then, use str_replace to replace the _ with a space:
    PHP Code:
    $newInv str_replace("_"""$inv); 
    Notice: If you post a problem and it gets fixed, please remember to go back and place it as solved. ;)
    I always recommend the HEAD First series of books for learning a new coding language. ^_^

    Comment


    • #3
      Thanks I will try that, the reason it needs the space is because it has to match the database value exactly by name.
      Been a sign maker for 8 years. My business:
      American Made Signs

      Comment


      • #4
        http://www.php.net/urlencode

        Comment


        • #5
          Perfect, thanks guys
          Been a sign maker for 8 years. My business:
          American Made Signs

          Comment

          Working...
          X