SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with if statement

    Hi,

    I am trying to declaire the page title at the top, then change the class in the <li> tag to reffernce which page the person is on. However, all the <li> tags are active in the situation below... where am I going wrong? You can see that I have tried a few things...

    PHP Code:
    <? $pageid="Home"?>

    <ul>
        <li<? if ($pageid="Home") echo " class='active'"?>><a href="#">Home</a></li>
        <li<? if ($pageid="About Us")  echo " class='active'"?>><a href="#">About Us</a></li>
        <li<? if ($pageid="Services") { echo " class=\"active\"";}?>>Services</a></li>
        <li<? if ($pageid="Resources") { echo " class=\"active\"";}?>><a href="#">Resources</a></li>
        <li<? if ($pageid="Faqs") { echo " class=\"active\"";}?>><a href="#">Faqs</a></li>
        <li<? if ($pageid="Contact Us") { echo " class=\"active\"";}?>><a href="#">Contact Us</a></li>
        <li<? if ($pageid="Events") { echo " class=\"active\"";}?>><a href="#">Events</a></li>
    </ul>

  2. #2
    SitePoint Addict Fire59's Avatar
    Join Date
    Aug 2003
    Location
    mn
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it should be if($pageid == "whatever")
    == is for comparision
    and
    = is for setting value

  3. #3
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! ... I actually just caught the mistake as well.... Sometimes you just have to pace around the desk a few times

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    You are also missing some braces {}
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •