crazy/man Posted December 1, 2008 Share Posted December 1, 2008 Hi all, i dont't know how to explain this to you well but i have some problem as i am making new web site. i have links on my page that look like this: index.php?site=coverage so i click on that link and it includes new php site inside index.php and in navigationbar in your browser you can see this: http://mydomain.com/index.php?site=coverage but now i want to open one more site so new link should look like this: &video=video2 so how can i do that...so it automatically adds new link on existing navigation bar... so it looks like this: http://mydomain.com/index.php?site=coverage&video=video2 but it loads me this: http://mydomain.com/&video=video2 and ofc it isn't working Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/ Share on other sites More sharing options...
gevans Posted December 1, 2008 Share Posted December 1, 2008 It'd help if you post your code... Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703105 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 so all i am trying to say is there any way that my link are always added to index.php? so my link can always start with "&" edit.. what code you need i can send u all just let me solve this Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703108 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 thats the code i am trying to use but it still isnt working <a href="<?php echo $_SERVER['PHP_SELF'] ?>?&coverage=balanesports2"> well it does load page correctly but it loads it like this: http://mydomain.com/index.php?&coverage=balanesports2 and i need it to loead like this: http://mydomain.com/index.php?site=news&coverage=balanesports2 i just need newlink to be added on the old ones that are already loaded Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703127 Share on other sites More sharing options...
Garethp Posted December 1, 2008 Share Posted December 1, 2008 how about something like this $Path = "index.php?"; foreach($_GET as $k => $v) { $Path .= $k . "=" . $v . "&"; } $Path = substr($Path, 0, -1); Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703128 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 maybe i can try it but as i am php coding noob i really need some more help (where to add that code ..) so if you can somehow explain it to me over msn...or some instant chat program add me on support_styler@hotmail.com really would appreciate your help Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703135 Share on other sites More sharing options...
Garethp Posted December 1, 2008 Share Posted December 1, 2008 I added you but let me explain this //Base reference, the page you are on now $Path = "index.php?"; //Loop through all the $_GET value in your URL already foreach($_GET as $k => $v) { //Add them to path again $Path .= $k . "=" . $v . "&"; } //Get rid of last character, either & or ? if you have no $_GET values yet $Path = substr($Path, 0, -1); //Add your new variables here $Path .= "val1=a&val2=b"; //And then $Path with be your new URL! Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703141 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 still didnt solve it, guys tried to help me but...seems to be too hard... is there anyone that cuold solve this? pls add me on msn : support_styler@hotmail.com many thanks! i need to solve this problem today ( Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703187 Share on other sites More sharing options...
Maq Posted December 1, 2008 Share Posted December 1, 2008 still didnt solve it, guys tried to help me but...seems to be too hard... Can you show us your current code because the solution Garethp provided should work... Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703195 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 well i dont know which code you need, you need index.php site code or that another pages thast are included codes? for link i am using normal HTML link code... Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703198 Share on other sites More sharing options...
Maq Posted December 1, 2008 Share Posted December 1, 2008 well i dont know which code you need, you need index.php site code or that another pages thast are included codes? The code where you generate the URL, that's where the problem is right? Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703201 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 yeah i just dont know how the link should look like this is one i use now <a href="&coverage=more">read more</a> index.php is almost full HTML it got only php include scripts... i do not use mysql for site.. www.hr-clan.com/newsite Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703205 Share on other sites More sharing options...
Maq Posted December 1, 2008 Share Posted December 1, 2008 Ok try this (added some things to Garethp's): //Base reference, the page you are on now $Path = "index.php?"; //keep track of how many gets you've added on $x = 0; //Loop through all the $_GET value in your URL already foreach($_GET as $k => $v) { //Add them to path again $Path .= $k . "=" . $v . "&"; //increment x everything you add a GET variable on $x++; } //Get rid of last character, either & or ? if you have no $_GET values yet $Path = substr($Path, 0, -1); //if x == 0 use ? if not use & $Path .= ($x == 0) ? "?coverage=more" : "&coverage=more"; //And then $Path with be your new URL! read more Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703210 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 thanks, but should i add this code to index.php or to balkanesports.php page? i tried to add it on "balkanesports.php" on the place where link should go, i pasted this: <? //Base reference, the page you are on now $Path = "index.php?"; //keep track of how many gets you've added on $x = 0; //Loop through all the $_GET value in your URL already foreach($_GET as $k => $v) { //Add them to path again $Path .= $k . "=" . $v . "&"; //increment x everything you add a GET variable on $x++; } //Get rid of last character, either & or ? if you have no $_GET values yet $Path = substr($Path, 0, -1); //if x == 0 use ? if not use & $Path .= ($x == 0) ? "?coverage=balkanesports2" : "&coverage=balkanesports2"; //And then $Path with be your new URL! <a href="<?php $_SERVER['PHP_SELF'] . $Path; ?>">read more</a>?> Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703221 Share on other sites More sharing options...
Maq Posted December 1, 2008 Share Posted December 1, 2008 Should be whatever page you want the LINK to show up on. Sorry, use this code, I forgot to close the PHP tags in my previous post. (Side note: Never use short tags, , always use, <?php) //Base reference, the page you are on now $Path = "index.php?"; //keep track of how many gets you've added on $x = 0; //Loop through all the $_GET value in your URL already foreach($_GET as $k => $v) { //Add them to path again $Path .= $k . "=" . $v . "&"; //increment x everything you add a GET variable on $x++; } //Get rid of last character, either & or ? if you have no $_GET values yet $Path = substr($Path, 0, -1); //if x == 0 use ? if not use & $Path .= ($x == 0) ? "?coverage=balkanesports2" : "&coverage=balkanesports2"; ?> //And then $Path with be your new URL! read more Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703236 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 ok i pasted that code to the balkanesports.php page that contains link to balkanesports2.php page here it is and doesnt work link doesnt work... http://www.hr-clan.com/newsite/ check that coverage field in the middle Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703243 Share on other sites More sharing options...
Maq Posted December 1, 2008 Share Posted December 1, 2008 Replace: ?> //And then $Path with be your new URL! read more With this: //And then $Path with be your new URL! echo $Path; ?> read more Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703248 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 i did now, i have a feeling that you are so close, but it doesnt work yet.. Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703250 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 i've noticed that i loads good link as you can see here http://www.hr-clan.com/newsite/index.php?news=10 but it doesn convert it to URL...it is just text file.. Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703256 Share on other sites More sharing options...
Maq Posted December 1, 2008 Share Posted December 1, 2008 I'm really off today. I forgot to echo the variable in the HTML link. Try this: //Base reference, the page you are on now $Path = $_SERVER['PHP_SELF'] . "index.php?"; //keep track of how many gets you've added on $x = 0; //Loop through all the $_GET value in your URL already foreach($_GET as $k => $v) { //Add them to path again $Path .= $k . "=" . $v . "&"; //increment x everything you add a GET variable on $x++; } //Get rid of last character, either & or ? if you have no $_GET values yet $Path = substr($Path, 0, -1); //if x == 0 use ? if not use & $Path .= ($x == 0) ? "?coverage=balkanesports2" : "&coverage=balkanesports2"; echo $Path; //And then $Path with be your new URL! ?> read more Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703261 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 hmmm still some small error it puts twice index.php as you can see here http://hr-clan.com/newsite and draws link as text... i have feeling you are close realy close now Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703266 Share on other sites More sharing options...
Maq Posted December 1, 2008 Share Posted December 1, 2008 Change this line to: $Path = $_SERVER['PHP_SELF']; I just echo it to see what the link is. You don't need that in there because you can hover over the hyperlink and see it. Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703274 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 oke now i replaced that line.. and now it misses just one letter it is letter "p" at the index.ph :S Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703280 Share on other sites More sharing options...
Maq Posted December 1, 2008 Share Posted December 1, 2008 Lol, use this: $Path = $_SERVER['PHP_SELF'] . "?"; Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703286 Share on other sites More sharing options...
crazy/man Posted December 1, 2008 Author Share Posted December 1, 2008 yeaa man you've made it!! congratz!! many many many thanks for this one ...oh...i dont know how to thank you really i appreciate your time and what yuo've done for me great now i can finish my site btw your opinion about site design? Quote Link to comment https://forums.phpfreaks.com/topic/135003-solved-dynamic-link-help/#findComment-703289 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.