New to PHP - Help please?

Hey guys, just started converting my site to php, so that I can use the include function thingy, haha (technical terms ftw!)

My site is www.maniacstudios.com

Well, I am having a bit of a problem. This is what my old navigation code looked liked

<div class="nav">
	   <ul>
		<li><a href="contact.html">contact</a></li>
		<li><a href="folio.html">portfolio</a></li>
		<li class="active"><a href="index.html">home</a></li>
	  </ul>

	 </div>

AS you can see, the link that was active was supposed to do something.

But now that I use one navigation file for all pages, how do I get it so that each individual page can have an active style? Basically I want it the way it was before I switched to php, but I still want one file for all pages.

Dont know if that made sense? sorry

well I just copied and pasted what you gave me


<div class="nav">
  <ul>
    <li<?php if($page == 'contact') echo ' class="active"' ?>><a href="contact.php">contact</a></li>
    <li<?php if($page == 'folio') echo ' class="active"' ?>><a href="folio.php">portfolio</a></li>
    <li<?php if($page == 'index') echo ' class="active"' ?>><a href="index.php">home</a></li>
  </ul>
</div>

nevermind, I figured it out.

I had to define the page names. Thanks man

Can’t check your php code in a browser :slight_smile:

I tried that, but it doesnt seem to work?

here is my site, you can check my code www.maniacstudios.com


<div class="nav">
  <ul>
    <li<?php if($page == 'contact') echo ' class="active"' ?>><a href="contact.html">contact</a></li>
    <li<?php if($page == 'folio') echo ' class="active"' ?>><a href="folio.html">portfolio</a></li>
    <li<?php if($page == 'index') echo ' class="active"' ?>><a href="index.html">home</a></li>
  </ul>
</div>

You can just set $page= directly in the page, or do it dynamically looking at $_SERVER vars