Jump to content

Archived

This topic is now archived and is closed to further replies.

Dville

current page question

Recommended Posts

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

Share this post


Link to post
Share on other sites
On page1.php......
[code]
$page = 'page1.php';

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

Share this post


Link to post
Share on other sites
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?

Share this post


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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.