freelance84 Posted April 26, 2010 Share Posted April 26, 2010 I have managed to get a variable into the URL: ...nts.php?table=tester1 But how do I get the value of table out of it? Quote Link to comment Share on other sites More sharing options...
aeroswat Posted April 26, 2010 Share Posted April 26, 2010 I have managed to get a variable into the URL: ...nts.php?table=tester1 But how do I get the value of table out of it? $_GET['table'] Quote Link to comment Share on other sites More sharing options...
freelance84 Posted April 26, 2010 Author Share Posted April 26, 2010 thank you. I think i've been staring at my screen too long today, I tried that but it didn't work before, now it does Quote Link to comment Share on other sites More sharing options...
aeroswat Posted April 26, 2010 Share Posted April 26, 2010 thank you. I think i've been staring at my screen too long today, I tried that but it didn't work before, now it does lol np Quote Link to comment Share on other sites More sharing options...
trevorsg Posted April 26, 2010 Share Posted April 26, 2010 Here's another way: function get_params() { unset($_GET); //Frees up some memory $uri = explode('?', $_SERVER['REQUEST_URI']); $queryStr = $uri['1']; $vars = explode('&', $queryStr); $getVars = array(); foreach ($vars as $var) { $exp = explode('=', $var); $getVars[$exp[0]] = $exp[1]; } return $getVars; } And then you can use it to make any variable contain an array with your get variables! $some_var = get_params(); //your 'tester1' can be accessed by $some_var['table'] I know the above works because I read it on 4chan. Quote Link to comment Share on other sites More sharing options...
aeroswat Posted April 26, 2010 Share Posted April 26, 2010 Here's another way: function get_params() { unset($_GET); //Frees up some memory $uri = explode('?', $_SERVER['REQUEST_URI']); $queryStr = $uri['1']; $vars = explode('&', $queryStr); $getVars = array(); foreach ($vars as $var) { $exp = explode('=', $var); $getVars[$exp[0]] = $exp[1]; } return $getVars; } And then you can use it to make any variable contain an array with your get variables! $some_var = get_params(); //your 'tester1' can be accessed by $some_var['table'] I know the above works because I read it on 4chan. Why would you ever do that? Quote Link to comment Share on other sites More sharing options...
trevorsg Posted April 26, 2010 Share Posted April 26, 2010 Why would you ever do that? Sorry, just being humorous. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.