0

I have a navigation like this:

<div class="navigation" id="<?php echo $page ?>">
    <ul>
        <li>`<a class="home" href="index">Home</a>`</li>
        <li>`<a class="training-gallery" href="training-gallery">Training Gallery</a>`</li>
        <li>`<a class="products-and-merchandise" href="products-and-merchandise">Products &amp; Merchandise</a><`/li>
        <li>`<a class="facebook-page" href="facebook-page">Personal Training on Facebook</a>`</li>
        <li>`<a class="personal-training-forum" href="client-feedback">Client Feedback</a>`</li>
        <li>`<a class="dannys-blog" href="dannys-blog">Danny's Blog</a>`</li>
    </ul>
</div>

in my page, I have put the following line of code at the top of the page of a page called training gallery:

<?php $page ='training-gallery' ?>

On my website when I inspect the element using firebug, I get a message like:

Notice: Undefined variable: page in /Applications/XAMPP/xamppfiles/htdocs/Websites/twd/dtpt/includes/navigation.php on line 1
on the link of the training gallery page.

I am assuming I need a GET method instead of this simple bit of code to say that if you are on the training-gallery page, put the name of the page training-gallery on the navigation id line in the code. by defining where the page is. Hopes this makes sense.

Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
Wizard
  • 31
  • 6
  • Please don't include links in your questions to external sites. Include all relevant code in your question's body. – Qix - MONICA WAS MISTREATED Oct 04 '14 at 21:38
  • Thanks for letting me know. I'm new to this so please excuse my error – Wizard Oct 04 '14 at 21:40
  • No problem :) If you have a moment, check out [How to Ask A Question](http://stackoverflow.com/help/how-to-ask). It's a great resource for getting fast and meaningful responses ;) – Qix - MONICA WAS MISTREATED Oct 04 '14 at 21:41
  • I don't see the error on your site. Also, I don't know what you mean by a 'get method'. It sounds like you don't mean what the tag says (the HTTP GET method), but it's not clear to me what you do mean. Normally simple code is enough to get you going. Actually, a PHP file can contain just static HTML and it will still work. – GolezTrol Oct 04 '14 at 21:42
  • an obvious question would be, do you define the variable before the navigation or after? `` needs to be before the navigation code. – Thanos Tourikas Oct 04 '14 at 21:47
  • After checking, this only seems to be an error when I'm working on my local machine as I have got errors turned on. I ideally want to fix these errors, even though they are not showing live. if I'm going to do a job, I might as well do it right. :) I am putting the little bit of php coding on the navigation div I'd line but I'm guessing I can't just put the php code as as I need to somehow tell the browser that if u reach the page training gallery, show the ID name in the navigation to the title of the page – Wizard Oct 06 '14 at 12:11

1 Answers1

0

Yes, you do need a GET parameter :-)

In the link, you can specify: <a href="?page=home

and in php

<?php
$page = (isset($_GET['page'])) ? $_GET['page'] : '';
  • this will check, whether the $_GET['page'] exists and if not, it will set the $page to empty string...