FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP has stopped displaying my nav





welshsteve
Hi everyone. I had some code earlier today that was working absolutely fine. Now although I've made no change to it, it's stopped working. I'm using some techniques to include navigation and highlight the currently displayed page in the nav.

To explain my problem, the below "snooker" files work.

snooker.php
Code:

<?php
include 's_nav.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Leamington and District Billiards and Snooker Association</title>

   <meta http-equiv="Content-Type" content="text/html; charset=shift_jis">

   <link rel="stylesheet" type="text/css" href="snooker_files/mainstyles.css"></head>
   <body>

<!-- START HEADER -->
<div id="header">
   <?php echo $topnav; ?>
</div>
<!-- END HEADER -->
<!-- START wrapper -->
<div id="wrapper">
   <!-- NAVIGATION -->
   <div class="nav">
      <br>
      <h2>Snooker</h2>
<?php echo $s_sidenav; ?>      
   </div>
   <!-- CONTENT -->
   <div class="content">
   Content here
   </div>
   <!-- RIGHT -->
   <div class="right">
   <?php include("links_external.php"); ?>      
   </div>
</div>   
<!-- END wrapper -->
<!-- START FOOTER -->
<div id="footer">
   <?php include 'footer.php';?>
</div>
<!-- END FOOTER -->

</body></html>

s_nav.php
Code:

<?php
$base=basename($_SERVER['PHP_SELF']);
$page=explode('.',$base); $page=$page[0];
$s_pages=array('snooker','s_fixtures','s_results','s_tables','s_stats','s_cup','s_individual','s_history','s_cup_3man','s_cup_fredcowell','s_cup_handicap','s_cup_ind','s_cup_over50','s_cup_pairs','s_cup_supp','s_cup_under35','s_fix_a','s_fix_b','s_fix_prem','s_res_a','s_res_b','s_res_prem');
$s_cuppages=array('s_cup_3man','s_cup_fredcowell','s_cup_handicap','s_cup_ind','s_cup_over50','s_cup_pairs','s_cup_supp','s_cup_under35');
$s_fixpages=array('s_fix_a','s_fix_b','s_fix_prem');
$s_respages=array('s_res_a','s_res_b','s_res_prem');
$s_sidenav='<ul class="sidenav">
      <li><a href="snooker.php">Latest news</a></li>
      <li><a href="s_fixtures.php">Fixtures</a></li>
      <li><a href="s_results.php">Results</a></li>
      <li><a href="s_tables.php">Tables</a></li>
      <li><a href="s_stats.php">Player Stats</a></li>
      <li><a href="s_cup.php">Cup</a></li>
      <li><a href="s_individual.php">Individual</a></li>
      <li><a href="s_history.php">History</a></li>
      </ul>';
$s_sidenav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $s_sidenav);
$topnav='<ul class="navigation">
      <li id="g"><a href="rss.php" accesskey="8">RSS</a></li>
      <li id="f"><a href="feedback.php" accesskey="7">Feedback</a></li>
      <li id="e"><a href="rules.php" accesskey="6">Rules</a></li>
      <li id="d"><a href="clubs.php" accesskey="5">Clubs</a></li>
      <li id="c"><a href="officers.php" accesskey="4">Officers</a></li>
      <li id="b"><a href="billiards.php" accesskey="3">Billiards</a></li>
      <li id="b"><a href="snooker.php" accesskey="2">Snooker</a></li>
      <li id="a"><a href="index.php" accesskey="1">Home</a></li>
   </ul>';
$base=basename($_SERVER['PHP_SELF']);
$page=explode('.',$base); $page=$page[0];
if (in_array($page,$s_pages)) {
   $topnav=preg_replace("|<li(.*)><a href=\"snooker.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $topnav);
}
else {
   $topnav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $topnav);
}
if (in_array($page,$s_cuppages)) {
   $topnav=preg_replace("|<li(.*)><a href=\"snooker.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $topnav);
   $s_sidenav=preg_replace("|<li(.*)><a href=\"s_cup.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $s_sidenav);
}
else {
   $topnav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $topnav);
   $s_sidenav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $s_sidenav);
}
if (in_array($page,$s_fixpages)) {
   $topnav=preg_replace("|<li(.*)><a href=\"snooker.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $topnav);
   $s_sidenav=preg_replace("|<li(.*)><a href=\"s_fixtures.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $s_sidenav);
}
else {
   $topnav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $topnav);
   $s_sidenav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $s_sidenav);
}
if (in_array($page,$s_respages)) {
   $topnav=preg_replace("|<li(.*)><a href=\"snooker.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $topnav);
   $s_sidenav=preg_replace("|<li(.*)><a href=\"s_results.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $s_sidenav);
}
else {
   $topnav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $topnav);
   $s_sidenav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $s_sidenav);
}

?>


But the below "billiards" files are not working correctly. The sidenav is not displaying.

billiards.php
Code:

<?php
include 'b_nav.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

   <title>Leamington and District Billiards and Snooker Association</title>

   <meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />

   <link rel="stylesheet" type="text/css" href="snooker_files/mainstyles.css" />   
   
</head>

<body id="p3">

<!-- START HEADER -->
<div id="header">
<?php echo $topnav; ?>      
</div>
<!-- END HEADER -->
<!-- START wrapper -->
<div id="wrapper">
   <!-- NAVIGATION -->
   <div class="nav">
      <br />
      <h2>Billiards</h2>
<?php echo $b_sidenav; ?>      
   </div>
   <!-- CONTENT -->
   <div class="content">
      Content here
   </div>
   <!-- RIGHT -->
   <div class="right">
   <?php include("links_external.php"); ?>      
   </div>
</div>   
<!-- END WRAPPER -->
<!-- START FOOTER -->
<div id="footer">
   <?php include 'footer.php';?>
</div>
<!-- END FOOTER -->

</body>
</html>

b_nav.php
Code:

<?php
$base=basename($_SERVER['PHP_SELF']);
$page=explode('.',$base); $page=$page[0];
$b_pages=array('billiards','b_fixtures','b_results','b_table','b_stats','b_cup','b_individual','b_history','b_cup_brum','b_cup_camkin','b_cup_ken','b_morris');
$b_cuppages=array('b_cup_brum','b_cup_camkin','b_cup_ken');
$b_sidenav='<ul class="sidenav">
      <li><a href="billiards.php">Latest news</a></li>
      <li><a href="b_fixtures.php">Fixtures</a></li>
      <li><a href="b_results.php">Results</a></li>
      <li><a href="b_table.php">Tables</a></li>
      <li><a href="b_morris.php">Morris Trophy</a></li>
      <li><a href="b_stats.php">Player Stats</a></li>
      <li><a href="b_cup.php">Cup</a></li>
      <li><a href="b_individual.php">Individual</a></li>
      <li><a href="b_history.php">History</a></li>
      </ul>';
$b_sidenav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $b_sidenav);
$topnav='<ul class="navigation">
      <li id="g"><a href="rss.php" accesskey="8">RSS</a></li>
      <li id="f"><a href="feedback.php" accesskey="7">Feedback</a></li>
      <li id="e"><a href="rules.php" accesskey="6">Rules</a></li>
      <li id="d"><a href="clubs.php" accesskey="5">Clubs</a></li>
      <li id="c"><a href="officers.php" accesskey="4">Officers</a></li>
      <li id="b"><a href="billiards.php" accesskey="3">Billiards</a></li>
      <li id="b"><a href="snooker.php" accesskey="2">Snooker</a></li>
      <li id="a"><a href="index.php" accesskey="1">Home</a></li>
   </ul>';
$base=basename($_SERVER['PHP_SELF']);
$page=explode('.',$base); $page=$page[0];
if (in_array($page,$b_pages)) {
   $topnav=preg_replace("|<li(.*)><a href=\"billiards.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $topnav);
}
else {
   $topnav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $topnav);
}
if (in_array($page,$b_cuppages)) {
   $topnav=preg_replace("|<li(.*)><a href=\"billiards.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $topnav);
   $b_sidenav=preg_replace("|<li(.*)><a href=\"b_individual.php\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>",    $sidenav);
}
else {
   $topnav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $topnav);
   $b_sidenav=preg_replace("|<li(.*)><a href=\"".$base."\".*>(.*)</a></li>|U", "<li$1 class=\"current\">$2</li>", $sidenav);
}

?>
welshsteve
My bad. I had $sidenav instead of $b_sidenav in a couple of lines. Missed them earlier Confused
Related topics
Rate us at ClickHereFree!
Script php about gallery
PHP Toturail
Easy way to do sidepanel links?
Co myslicie o mojej stronce??
Phoenix free PHP scripts
PHP Image suddenly doesn't work?
PHP index page not displaying problem
Problem with Image upload mod from phpBBstyles
navigation system probs
Open 2 Directorys at Once.
Error trying to display SQL statement in html table
include() Problem
Adding a Nav Bar to my PHP forum
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.