saeed_violinist Posted June 18, 2007 Share Posted June 18, 2007 Dear friends, Is there a way to save a url's "get method" part and save it to a variable? let me show you an example. I have a url like this in browsers address bar-> http://www.mysite.com/?page=about-us Now I want to save "about-us" in a variable and do a mysql query about it! Is there a way to do this without knowing the actual statement after ?page= ? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/56112-how-to-save-a-get-element-from-an-url/ Share on other sites More sharing options...
cooldude832 Posted June 18, 2007 Share Posted June 18, 2007 $var = $_GET['page']; that simple the advantage of GET is you can make links to them like echo "<a href=\"page.html?page=\"".$pagenumber."\">Page</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/56112-how-to-save-a-get-element-from-an-url/#findComment-277159 Share on other sites More sharing options...
saeed_violinist Posted June 18, 2007 Author Share Posted June 18, 2007 wow thanks Quote Link to comment https://forums.phpfreaks.com/topic/56112-how-to-save-a-get-element-from-an-url/#findComment-277160 Share on other sites More sharing options...
cooldude832 Posted June 18, 2007 Share Posted June 18, 2007 also note how its a global (noted with the $_ ) so it can be called inside functions. Quote Link to comment https://forums.phpfreaks.com/topic/56112-how-to-save-a-get-element-from-an-url/#findComment-277162 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.