Jump to content


Photo

current page question


  • Please log in to reply
5 replies to this topic

#1 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 10 July 2006 - 09:02 PM

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 do

if - current page = page1.php
show this code

so that when you view the table from page2.php it doesnt show the link to the page im already at

thanks in advanced for anyone who can help


#2 realjumper

realjumper
  • Members
  • PipPipPip
  • Advanced Member
  • 399 posts

Posted 10 July 2006 - 10:11 PM

On page1.php......
$page = 'page1.php';

if ($page == 'page1.php')
 {
  echo "Show this code";
 }


#3 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 11 July 2006 - 02:35 AM

I dont get it?

1 - why only single quotes
2 - 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?



#4 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 11 July 2006 - 02:39 AM

<?php
$self = $_SERVER['PHP_SELF'];
$arr = split("/", $self);
$num = count($arr);
if($arr[$num - 1] == "page1.php"){
	/* run code */
}
?>


#5 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 11 July 2006 - 02:56 AM

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.php

but 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

#6 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 11 July 2006 - 03:00 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users