blesseld Posted August 18, 2009 Share Posted August 18, 2009 Hey All, I believe what i am trying to do is very simple, but no where actually explains the first part. All i would like to do is add a variable to my URL. I have a file that sets all the page id's for all the pages on my site. and gets included on all pages. how can i get it to show up at the end of my URL? here is a chunk of my file that sets the variables <?php switch ($sheet_name) { case 'homepage': { $page_id = "1"; $current_link = "home"; $dir_listing = "false"; $title ="title"; $meta_desc = "description"; $meta_key = "keywords"; break; } ?> I am tryng to get http://www.domain.com?page_id=1 thanks Link to comment https://forums.phpfreaks.com/topic/170839-just-need-to-add-variable-to-url-cant-find-clear-answer/ Share on other sites More sharing options...
fooDigi Posted August 18, 2009 Share Posted August 18, 2009 could it be just this? ... http://www.domain.com?page_id=<?php echo $page_id ?> Link to comment https://forums.phpfreaks.com/topic/170839-just-need-to-add-variable-to-url-cant-find-clear-answer/#findComment-900967 Share on other sites More sharing options...
blesseld Posted August 18, 2009 Author Share Posted August 18, 2009 Yes, that works, thankyou, However, is there a way i can toss it in the URL without having to add the echo to all of my links? Like some kinda script I can place in my variables file to auto toss it in the url? this is more what im after, shoulda been more clear. Link to comment https://forums.phpfreaks.com/topic/170839-just-need-to-add-variable-to-url-cant-find-clear-answer/#findComment-900978 Share on other sites More sharing options...
mikesta707 Posted August 18, 2009 Share Posted August 18, 2009 Don't believe there is a way to set a get variable without explicitly setting them in the links themselves. Especially if each one is going to be different depending on which link you set. The only way I see making creating the links easier is if you store your get values in an array, and create the links by iterating through the array. Link to comment https://forums.phpfreaks.com/topic/170839-just-need-to-add-variable-to-url-cant-find-clear-answer/#findComment-900991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.