Is there a similar statement to "document.getElementById()" in PHP? I want to be able to specify where to include() a file.
You have two understand the difference between PHP and JavaScript.
Javascript is a client side language, ie. it operates on your browser after the page has loaded and allows you to change stuff on the page without needing to reload.
PHP is a server side language which executes on the server and then sends, in most cases, a static HTML page to the person who requested it. All changes made with PHP on a page do require a reload to take effect.
Therefore if you want to include a different page on each load in PHP then you could pass the information on what page is to be loaded through a querystring (the piece after the question mark in the URL). You could try something like this:
Code:
<?php
/* determine the pagename passed through the URL */
if(isset($_GET['pagename'])) $pagename = $_GET['pagename'];
else $pagename = 'home';
/* load a different include depending on the page selected */
switch ($pagename) {
case 'home':
include 'home.php';
break;
case 'about':
include 'about.php';
break;
case 'contact':
include 'contact.php';
break;
}
/* display navigation links with querystring attatched */
echo '
<ul>
<li><a href="index.php?pagename=home">Home</a></li>
<li><a href="index.php?pagename=about">About</a></li>
<li><a href="index.php?pagename=contact">Contact</a></li>
</ul>
';
Hope That Helps