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?
 
Roger BaklundConnect With a Mentor Commented:
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.