Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,445
    Thanks
    71
    Thanked 102 Times in 101 Posts

    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; 09-01-2011 at 03:03 PM.

  • #2
    Regular Coder
    Join Date
    Oct 2010
    Location
    Florence, MS
    Posts
    486
    Thanks
    10
    Thanked 33 Times in 32 Posts
    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. ^_^

  • Users who have thanked Chris Hick for this post:

    myfayt (09-01-2011)

  • #3
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,445
    Thanks
    71
    Thanked 102 Times in 101 Posts
    Thanks I will try that, the reason it needs the space is because it has to match the database value exactly by name.

  • #4

  • Users who have thanked gvre for this post:

    myfayt (09-01-2011)

  • #5
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,445
    Thanks
    71
    Thanked 102 Times in 101 Posts
    Perfect, thanks guys


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •