I want to add a nav bar using php include, but I have it in a loop in the navBar.php file:
<?php
$Links = array("index.php", "page1.php", "page2.php");
$Text = array("Home", "page1", "page2");
$ReqPage = (explode('/', $_SERVER['SCRIPT_NAME']));
echo $ReqPage[2];
$Nav="
<div id=\"navwrapper\">
<div id=\"nav\">
<ul id=\"navstuff\">
";
$j = 0;
foreach($Links as $ALink){
if ($ALink == $ReqPage){
$Nav .= "<li class=\"selected\"><a href=\"#\">";
} else{
$Nav .= "<li><a href=\"$ALink\">";
}
$Nav .= "$Text[$j]</a></li>
";
$j++;
}
$Nav .= "</ul>
</div>
</div>
";
echo $Nav;
?>
I have it in my index.php file as <?php include("navBar.php"); ?>
. It is not showing anything. Is it because I am not running off of a server? Currently I am opening the file by just typing in the file path into Chrome. Do I have to use a server for this? Also, If I have to use a server, what are some good ones for my computer (I don't want to pay money for large external servers)?