fbrown Posted February 2, 2007 Share Posted February 2, 2007 i have some code that makes a content box <?php if (isset($section) && $section != "") {include("/Inetpub/wwwroot/test1/".$section."".$page.".php");} else {$number = "1"; include 'welcome.php';} ?> my goal is to find a way to set $section to Enrollment <?php $section = "Enrollment"; ?> when somebody clicks on it so that the content box includes Enrollment.php now a friend gave me this code and i am not sure why the index $page is there i dont see it to be needed but this is the set up i have for a test <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="200" align="center"> <tr> <td> </td> <td><ul id="udm" class="udm"> <li><a class="nohref"></a> <ul> <li><a href="">Enrollment</a></li> <li><a href="">Courses</a></li> <li><a href="">Faculty</a></li> <li><a href="">Administration</a></li> <li><a href="">History</a></li> <li><a href="">Board of Directors</a></li> <li><a href="http://www.doe.state.la.us/lde/bese/855.html" target="_blank">What is a Charter School?</a></li> <li><a href="docs/charter.pdf">Ebrats Charter</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Downtown</a></li> <li><a href="">Partnerships</a></li> <li><a href="">Service Learning</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Student Life</a></li> <li><a href="">Seniors</a></li> <li><a href="">Juniors</a></li> <li><a href="">Sophomores</a></li> <li><a href="">Freshmen</a></li> <li><a href="">Pictures</a></li> <li><a href="">Internships</a></li> <li><a href="">Student Handbook</a></li> <li><a href="">Student Government</a></li> <li><a href="">ATM Reps</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Committees</a></li> <li><a href="">Volunteers</a></li> <li><a href="">Announcements/Info</a></li> <li><a href="">Comments/Questions</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Art Program</a></li> <li><a href="">Art Gallery</a></li> <li><a href="">Technology Program</a></li> <li><a href="">Tech Team</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Calendar</a></li> <li><a href="forum/index.php">Message Board</a></li> <li><a href="">Current Events</a></li> </ul> </li> <li><a class="nohref"></a> <ul class="style1"> <li><a target=new href="http://webmail.ebrats.org:90/exchange">Web mail</a></li> <li><a target=new href="http://www.ebrats.org:88/default.aspx">Share Point</a></li> </ul> </li> </ul> </td> <td> </td> </tr> <tr> <td height="222"> </td> <td><?php if (isset($section) && $section != "") {include("/Inetpub/wwwroot/test1/".$section."".$page.".php");} else {$number = "1"; include 'welcome.php';} ?></td> <td> </td> </tr> </table> </body> </html> any thoughts ive seen it work but it was so long ago i cant remember how Quote Link to comment Share on other sites More sharing options...
.josh Posted February 2, 2007 Share Posted February 2, 2007 <li><a href="<?php echo {$_SERVER['PHP_SELF']}; ?>?section=enrollment">Enrollment</a></li> . . . $section = $_GET['section']; Quote Link to comment Share on other sites More sharing options...
fbrown Posted February 2, 2007 Author Share Posted February 2, 2007 i got an error PHP Parse error: parse error, unexpected '{' in C:\Inetpub\wwwroot\test 1\ebrats1.php on line 15 i removed the {} braces and the error whent away but the link still didnt work :'( tear Quote Link to comment Share on other sites More sharing options...
.josh Posted February 2, 2007 Share Posted February 2, 2007 repost your code Quote Link to comment Share on other sites More sharing options...
fbrown Posted February 2, 2007 Author Share Posted February 2, 2007 <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="200" align="center"> <tr> <td> </td> <td><ul id="udm" class="udm"> <li><a class="nohref"></a> <ul> <li><a href="<?php echo $_SERVER['PHP_SELF']; ?>?section=Enrollment">Enrollment</a></li> <li><a href="">Courses</a></li> <li><a href="">Faculty</a></li> <li><a href="">Administration</a></li> <li><a href="">History</a></li> <li><a href="">Board of Directors</a></li> <li><a href="http://www.doe.state.la.us/lde/bese/855.html" target="_blank">What is a Charter School?</a></li> <li><a href="docs/charter.pdf">Ebrats Charter</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Downtown</a></li> <li><a href="">Partnerships</a></li> <li><a href="">Service Learning</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Student Life</a></li> <li><a href="">Seniors</a></li> <li><a href="">Juniors</a></li> <li><a href="">Sophomores</a></li> <li><a href="">Freshmen</a></li> <li><a href="">Pictures</a></li> <li><a href="">Internships</a></li> <li><a href="">Student Handbook</a></li> <li><a href="">Student Government</a></li> <li><a href="">ATM Reps</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Committees</a></li> <li><a href="">Volunteers</a></li> <li><a href="">Announcements/Info</a></li> <li><a href="">Comments/Questions</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Art Program</a></li> <li><a href="">Art Gallery</a></li> <li><a href="">Technology Program</a></li> <li><a href="">Tech Team</a></li> </ul> </li> <li><a class="nohref"></a> <ul> <li><a href="">Calendar</a></li> <li><a href="forum/index.php">Message Board</a></li> <li><a href="">Current Events</a></li> </ul> </li> <li><a class="nohref"></a> <ul class="style1"> <li><a target=new href="http://webmail.ebrats.org:90/exchange">Web mail</a></li> <li><a target=new href="http://www.ebrats.org:88/default.aspx">Share Point</a></li> </ul> </li> </ul> </td> <td> </td> </tr> <tr> <td height="222"> </td> <td><?php if (isset($section) && $section != "") {include("/Inetpub/wwwroot/test1/".$section."".$page.".php");} else {$number = "1"; include 'welcome.php';} $section = $_GET['section']; ?></td> <td> </td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
fbrown Posted February 2, 2007 Author Share Posted February 2, 2007 this error is now on the page that is with the newly posted code PHP Notice: Undefined index: section in C:\Inetpub\wwwroot\test 1\Untitled-1.php on line 90 Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 2, 2007 Share Posted February 2, 2007 Change this line: <?php if (isset($section) && $section != "") To this: <?php if (isset($_GET['section']) && $_GET['section'] != "") Quote Link to comment Share on other sites More sharing options...
fbrown Posted February 2, 2007 Author Share Posted February 2, 2007 well i gues we are moving farword welcome.php isnt there now but this error is on the page PHP Notice: Undefined variable: section in C:\Inetpub\wwwroot\test 1\Untitled-1.php on line 87 PHP Notice: Undefined variable: page in C:\Inetpub\wwwroot\test 1\Untitled-1.php on line 87 PHP Warning: include(/Inetpub/wwwroot/test1/.php) [function.include]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\test 1\Untitled-1.php on line 87 PHP Warning: include() [function.include]: Failed opening '/Inetpub/wwwroot/test1/.php' for inclusion (include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\test 1\Untitled-1.php on line 87 Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 2, 2007 Share Posted February 2, 2007 under that line I just fixed, add $section = $_GET['section']; It's telling you section is undefined, so you need to define it. Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted February 2, 2007 Share Posted February 2, 2007 Yeh, you've put that line a bit too low. You also need to define $page as well. Quote Link to comment Share on other sites More sharing options...
fbrown Posted February 2, 2007 Author Share Posted February 2, 2007 i got it to work i really didnt need $page or $section i gues the two would come in handy but idk this is what i came up with and it works really nice <?php if (isset($_GET['section'])) {include($_GET['section'].".php");} else {$number = "1"; include 'welcome.php';} ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.