...

View Full Version : Resolved Sending a name instead of id in a function



myfayt
09-01-2011, 02:27 AM
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


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:


equipinv.php?x=burn:3912

But I need it to show the name, and the name has spaces.

Chris Hick
09-01-2011, 04:07 AM
Sure, its simple really. You could use something like this when a user clicks on an item:


equipinv.php?x=burn:Blunt_Dagger

Then, use the get method to retrieve the variable:


$inv = $_GET["x"];

Then, use str_replace to replace the _ with a space:


$newInv = str_replace("_", "", $inv);

myfayt
09-01-2011, 01:38 PM
Thanks I will try that, the reason it needs the space is because it has to match the database value exactly by name.

gvre
09-01-2011, 01:44 PM
http://www.php.net/urlencode

myfayt
09-01-2011, 02:06 PM
Perfect, thanks guys



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum