1 Reply Latest reply on Oct 18, 2010 11:12 PM by w1n78

    how to show down state on <a>

    lazlo

      Hi,

       

      I'm calling my main navigation from a Mysql db recordset with a repeat region:

       

           <?php do { ?>
              <li><a href="#" title="xx"><?php echo $row_mcat['mcatNAME']; ?></a></li>
              <?php } while ($row_mcat = mysql_fetch_assoc($mcat)); ?>

       

      I have the following CSS for a a;pseudo classes:

       

      #navInner a:link, #navInner a:active, #navInner a:visited {
      height: 40px;
      line-height: 40px;
      background: #009343;
      display: block;
      text-align: center;
      float: left;
      border-right: thin double #333;
      color: #FFF;
      text-decoration: none;
      padding-left: 20px;
      padding-right: 20px;
      }
      #navInner a:hover {
      height: 40px;
      line-height: 40px;
      background: #FFF;
      display: block;
      text-align: center;
      float: left;
      border-right: thin double #333;
      color: #333;
      text-decoration: none;
      padding-left: 20px;
      padding-right: 20px;
      }

       

      on the page that these will link to, how can I show one link in a down state? (so it looks selected) if i give it a different class, all repeat regions will show in the down state.

       

      many thanks

        • 1. Re: how to show down state on <a>
          w1n78

          use a conditional statement within the loop and a css class that called .down-state

           

          let's say in your db table mcatNAME has the following values index, about, contact, help. each represent a different page.

           

          so in your index page you would have something like this...

           

          <?php

          $current_mcatNAME = 'index';         // variable stores the value that matches db table. if it matches, use .down-state css class, else use .up-state css class or none

          ?>

           

          <?php do { ?>

            <?php if ($current_mcatNAME <> $row_mcat['mcatNAME']) {  ?>
              <li><a href="#" title="xx"><?php echo $row_mcat['mcatNAME']; ?></a></li>

            <?php }else{ ?>

              <li><a href="#" title="xx" class="down-state"><?php echo $row_mcat['mcatNAME']; ?></a></li>

            <?php } ?>

          <?php } while ($row_mcat = mysql_fetch_assoc($mcat)); ?>

           

           

          $current_mcatNAME should equal whatever the current page's mcatNAME. hope that helps