showing where users are

im trying to show where users are on my forum.. just like this

*   PHP Freaks Forums > * PHP Coding >  * PHP Help >  * Start new topic

and i want it to be in just 1 file... so far i have this

<a href="http://www.runningprofiles.com/members/index.php?page=mainforums">runningprofiles forums</a> > <?php echo $forum; ?> > topic

with the topic i only want the link to show if they are on certain pages in my website.. so here are a few following examples

index.php?page=message
index.php?page=post
index.php?page=reply

could i make an if statement to somehow check if the user is viewing that page
runnerjpAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roger BaklundCommented:
I'm not sure if I understand, but something like this:

$page = $_REQUEST['page'];
$forumpages = array('message','post','reply');
if(in_array($page,$forumpages))
  $forum = '<a href="/members/index.php?page='.$page.'">'.$page.'</a>';
else $forum = '';

...and then use the $forum variable like in your example above.
0
runnerjpAuthor Commented:
ok i did something like this..

<?php
$show = array('message','post','reply');
if(in_array($_GET['page'],$show)) {
    echo 'foo';
}
?>

but cant i do something like

if($_GET['page']= post) {
    echo 'foo';
}
elseif($_GET['page']= message) {
    echo 'bar';
}
0
Roger BaklundCommented:
Yes... but you must use quotes and double ==:

if($_GET['page'] == 'post')

What about this:
$show = array(
  'message' => 'bar',
  'post' => 'foo',
  'reply' => 'foobar'
);
if(in_array($_GET['page'],array_keys($show))) {
  echo $show[ $_GET['page'] ];
}

Open in new window

0
runnerjpAuthor Commented:
that works great... could i add something like  'message' => '$messageid'

so that the message title would come up?


0
Roger BaklundCommented:
Yes, but then you would NOT use the single quotes, because $messageid is a variable: 'message' => $messageid

This only works if the $messageid variable contains the title... :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.