How to recognize which 'case' is being echoed by switch statement

From: Date: Fri, 22 Feb 2008 11:01:49 +0000
Subject: How to recognize which 'case' is being echoed by switch statement
Groups: php.db 
Request: Send a blank email to php-db+get-44640@lists.php.net to get a copy of this message
Hi, This is my first time using php in my site navigation, I have the code for all the pages in one file and I am using the switch statement to change between them. This is working great but I am now trying to change the css id of the current page's navbar link. How do I get my script to recognize which case is currently being echoed by the switch statement? If you want to see the page in action without php in the navbar visit here: http://www.publikdesign.com Here is the code: <html> <head> <link href="css/styles.css" rel="stylesheet" type="text/css"> </head> <body> <div id="page-container"> <!--- Header --->
        <div id="header">
        	<div id="nav">
            	<ul>
                	<?php
$page = case; if ( $page = "contact" ) { echo "<li id=\"contact-active\"></li>"; } else { echo "<li id=\"contact\"><a href=\"./?page=contact\">Contact</a></li>"; } ?>
                  	
                    <?php
if ( $page = "portfolio" ) { echo "<li id=\"portfolio_active\"></li>"; } else { echo "<li id=\"portfolio\"><a href=\"./?page=portfolio\">Portfolio</a></li>"; } ?>
                  	
                    <?php
if ( $page = "home" ) { echo "<li id=\"home-active\"></li>"; } else { echo "<li id=\"home\"><a href=\"./?page=home\">Home</a></li>"; } ?>
              </ul>
            </div>
        </div>
        <!--- End Header --->
<!--- Main --->
        <div id="main-content">
<?php
            switch($_GET['page']) {
            case "contact":
            echo "<!--- Left Content --->
        	<div id=\"left-content\">
            	<div id=\"left-top\">
                <ul>
                	<li><Strong>Phone</Strong> 0437 988 399</li>
                    <li><br /></li>
                    <li><Strong>eMail</Strong> <a href=\"mailto:tdaff@publikdesign.com\">tdaff@publikdesign.com</a></li>
                </ul>
                </div>
            </div>
            <!--- Right Content --->
            <div id=\"right-content\">
            	
            </div>";
            break;
            case "portfolio":
            echo "<!--- Left Content --->
        	<div id=\"left-content\">
            	
                <img src=\"images/portfolio/portfolio_heading.gif\" alt=\"Portfolio\" />
              <div id=\"port_img1\">
                <img src=\"images/portfolio/kdev_logo.gif\" alt=\"K Development Lofo\"  />
                <p class=\"caption-link\"><a href=\"?page=kdev\">Click to Expand</a></p>
              </div>
                <div id=\"port_img2\">
                <img src=\"images/portfolio/kmg_logo.gif\" alt=\"Katmandog Logo\"  />
                <p class=\"caption-link\"><a href=\"http://www.katmandog.biz\" target=\"_blank\">Click to visit website</a></p>
                </div>
          </div>
            <!--- Right Content --->
            <div id=\"right-content\">
            	
                <div id=\"port_img3\">
                <img src=\"images/portfolio/isl_logo.gif\" alt=\"Island Healing Logo\"  />
                <p class=\"caption-link\"><a href=\"?page=isl\">Click to Expand</a></p>
                </div>
                <div id=\"port_img4\">
                <img src=\"images/portfolio/re_logo.gif\" alt=\"Roaming Earth Logo\"  />
                <p class=\"caption-link\"><a href=\"?page=re\">Click to Expand</a></p>
                </div>
            </div>";
            break;
            case "home":
echo "<!--- Left Content --->
        	<div id=\"left-content\">
            	<div id=\"left-top\">
                <img src=\"images/dsgn_services.gif\" alt=\"Graphic Design Services\" width=\"327\" height=\"28\" />
                <p>Publik provides a full range of graphic design services, from business cards and letterheaders, to product catalogues and promotional brochures. We will bring your project from concept to print in the most cost effective and professional manner.</p>
              </div>
                <div id=\"left-bottom\">
                <img src=\"images/webdevel.gif\" alt=\"Web Development\" />
                <p>The world wide web has grown into the most powerful marketing tool available to a business. From a concreter to a department store, the internet can not be overlooked as an important tool in bringing clients to your business. Publik Design provides all manner of web services from static pages to fully dynamic web applications.</p>
                </div>
            </div>
            <!--- Right Content --->
            <div id=\"right-content\">
            	<div id=\"right-top\">
                <img src=\"images/kdev1.gif\" alt=\"K Development Business Card Design\" />
                </div>
                <div id=\"right-bottom\">
                <img src=\"images/katmandog_thumb.gif\" alt=\"Katmandog Pet Shop Thumbnail\" />
                </div>
            </div>";
break; case "kdev": echo "<!--- Left Content --->
        	<div id=\"left-content\">
            	
                <img src=\"images/portfolio/portfolio_heading.gif\" alt=\"Portfolio\" />
<p><a href=\"?page=portfolio\">Back</a></p>
                <div id=\"large1\">
                <img src=\"images/portfolio/kdev_expanded.gif\" alt=\"K Development\"  />
                </div>
          	</div>";
break; case "isl": echo "<!--- Left Content --->
        	<div id=\"left-content\">
            	
              <img src=\"images/portfolio/portfolio_heading.gif\" alt=\"Portfolio\" />
              <p><a href=\"?page=portfolio\">Back</a></p>
                <div id=\"large1\">
                <img src=\"images/portfolio/isl_expanded.gif\" alt=\"K Development\"  />
                </div>
       	  </div>";
break; case "re": echo "<!--- Left Content --->
        	<div id=\"left-content\">
            	
              <img src=\"images/portfolio/portfolio_heading.gif\" alt=\"Portfolio\" />
              <p><a href=\"?page=portfolio\">Back</a></p>
                <div id=\"large1\">
                <img src=\"images/portfolio/re_expanded.gif\" alt=\"K Development\"  />
                </div>
       	  </div>";
break;
            default:
            echo "<!--- Left Content --->
        	<div id=\"left-content\">
            	<div id=\"left-top\">
                <img src=\"images/dsgn_services.gif\" alt=\"Graphic Design Services\" width=\"327\" height=\"28\" />
                <p>Publik provides a full range of graphic design services, from business cards and letterheaders, to product catalogues and promotional brochures. We will bring your project from concept to print in the most cost effective and professional manner.</p>
              </div>
                <div id=\"left-bottom\">
                <img src=\"images/webdevel.gif\" alt=\"Web Development\" />
                <p>The world wide web has grown into the most powerful marketing tool available to a business. From a concreter to a department store, the internet can not be overlooked as an important tool in bringing clients to your business. Publik Design provides all manner of web services from static pages to fully dynamic web applications.</p>
                </div>
            </div>
            <!--- Right Content --->
            <div id=\"right-content\">
            	<div id=\"right-top\">
                <img src=\"images/kdev1.gif\" alt=\"K Development Business Card Design\" />
                </div>
                <div id=\"right-bottom\">
                <img src=\"images/katmandog_thumb.gif\" alt=\"Katmandog Pet Shop Thumbnail\" />
                </div>
            </div>";
            break;
            }
            ?>
</div> <!--- End Main ---> <!--- Footer --->
        <div id="footer">
       	
        <div id="footer-content">
        <p>&copy;2008 Publik Design<br /><a href="index.html">Home</a> <a href="portfolio.html">Portfolio</a> <a href="#">Contact</a></p>
        </div>
</div> </div> </body> </html>

« previous php.db (#44640) next »