Sebolains Posted December 7, 2007 Share Posted December 7, 2007 Hi. I want to define a variable depending on what it says in the url. This will always be ...index.php?p=105 . The number changes. I want to put the number to a variable or to acces to it troughout the code an other way. How do I do this? Quote Link to comment https://forums.phpfreaks.com/topic/80565-solved-how-do-you-store-sth-that-is-in-the-url-to-a-variable/ Share on other sites More sharing options...
trq Posted December 7, 2007 Share Posted December 7, 2007 <?php if (isset($_GET['p'])) { $var = $_GET['p']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/80565-solved-how-do-you-store-sth-that-is-in-the-url-to-a-variable/#findComment-408541 Share on other sites More sharing options...
Sebolains Posted December 7, 2007 Author Share Posted December 7, 2007 thanks !!! Quote Link to comment https://forums.phpfreaks.com/topic/80565-solved-how-do-you-store-sth-that-is-in-the-url-to-a-variable/#findComment-408546 Share on other sites More sharing options...
Sebolains Posted December 7, 2007 Author Share Posted December 7, 2007 OK. A problem arraised. The code is working perfectly, however, I need more than 1 ?p= in the url. I have the ?p=114 or wahatever and the ?e=news .They are separated by a & . However when I do this the variable doesn't seem to get the 114 (the ?p= is after the &). How do I solve this? Quote Link to comment https://forums.phpfreaks.com/topic/80565-solved-how-do-you-store-sth-that-is-in-the-url-to-a-variable/#findComment-408550 Share on other sites More sharing options...
Sebolains Posted December 7, 2007 Author Share Posted December 7, 2007 Solved It I wasn't supposed to put the second ? after the & jejeje. Sorry . thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/80565-solved-how-do-you-store-sth-that-is-in-the-url-to-a-variable/#findComment-408554 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.