Dville Posted July 10, 2006 Share Posted July 10, 2006 so i have a link on page1.php. that takes a variable to page2.php when clicked.Im looking to do an if/else statement to doif - current page = page1.phpshow this codeso that when you view the table from page2.php it doesnt show the link to the page im already atthanks in advanced for anyone who can help Quote Link to comment https://forums.phpfreaks.com/topic/14227-current-page-question/ Share on other sites More sharing options...
realjumper Posted July 10, 2006 Share Posted July 10, 2006 On page1.php......[code]$page = 'page1.php';if ($page == 'page1.php') { echo "Show this code"; }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14227-current-page-question/#findComment-55889 Share on other sites More sharing options...
Dville Posted July 11, 2006 Author Share Posted July 11, 2006 I dont get it?1 - why only single quotes2 - what makes $page so special? how is that linked to whatever page I am currently at?How I see it, I am just stuffing the string 'page1.php' into the variable. The code you show doesn't check the current page at all.Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/14227-current-page-question/#findComment-55964 Share on other sites More sharing options...
Prismatic Posted July 11, 2006 Share Posted July 11, 2006 [code]<?php$self = $_SERVER['PHP_SELF'];$arr = split("/", $self);$num = count($arr);if($arr[$num - 1] == "page1.php"){ /* run code */}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14227-current-page-question/#findComment-55970 Share on other sites More sharing options...
Dville Posted July 11, 2006 Author Share Posted July 11, 2006 This doesn't appear to work either.on your code, lines 3, 4, and the 'arr[$num - 1] i am not sure what it does.After thinking it through, since multiple pages use my code via the include function, I need it to be if 'the page im at now' != page2.phpbut even after changing your code, that doesn't seem to work. since you're using the php_self command, and my current url being page2.php?appid=65. is that making it not work, instead of it being just page2.php Quote Link to comment https://forums.phpfreaks.com/topic/14227-current-page-question/#findComment-55972 Share on other sites More sharing options...
Dville Posted July 11, 2006 Author Share Posted July 11, 2006 I am very sorry for the confusion. I thought i was using it as an include, but I am not. I have figured this out. Thanks for the help guys. Quote Link to comment https://forums.phpfreaks.com/topic/14227-current-page-question/#findComment-55973 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.