Results 1 to 2 of 2

Thread: Dynamic Page Content

  1. #1
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamic Page Content

    Good Morning All,

    I know there is an AJAX version of what I am trying to do , but I would also like to know the PHP version. Could someone review my code and tell me why I am getting a parsing error, please? The parsing error is reported at the closing body tag of the page. Thanks

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PHP content Change </title>
    <style type="text/css">
    li {
    	list-style-type: none;
    	display: inline;
    	margin-right: 15px;
    }
    </style>
    </head>
    
    <body>
    <img src="http://www.grass-rootsfoundation.org/images/grass4_r1_c1.jpg" width="980" height="114" />
    <h1>ABOUT US</h1>
    <ul>
      <li><a href="contentchange.php?link=1">President</a></li>
      <li><a href="contentchange.php?link=2">Staff</a></li>
      <li><a href="contentchange.php?link=3">Board of Directors</a></li>
    </ul>
    <?php
    if (isset($_REQUEST['link'])) {
    $link = $_REQUEST['link'];} 
    else {$link = 1;}
      switch ($link) {
      case 1:
      include ("aboutroots.html");
      break;
      case 2:
      include ("rootsstaff.html");
      break;
      case 3:
      include ("rootsdirectors.html");
      break;
      default:
      	$link = 1;
    	break;
     ?>
    </body>
    </html>

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    You didn't close your switch().

    This should work:
    PHP Code:
    if (isset($_REQUEST['link'])) {
    $link $_REQUEST['link'];} 
    else {
    $link 1;}
      switch (
    $link) {
      case 
    1:
      include (
    "aboutroots.html");
      break;
      case 
    2:
      include (
    "rootsstaff.html");
      break;
      case 
    3:
      include (
    "rootsdirectors.html");
      break;
      default:
          
    $link 1;
        break;
        } 

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
  •