A while ago I built a fan site for a PC game, and I believe that it could be set up better. Basically, right now all of my pages share a common header and footer, and the only real difference between pages is the content loaded into a main table cell.
Currently, I am trying to make 'clean' URLs by having each page in its own directory with an index.php file.
For example, my 'About' page is located in /about/index.php, but it can be accessed by just going to /about
Here is how the index.php looks inside of the 'about' directory:
<?php include '/home/content/69/7232369/html/loco_header.html' ?>
<tr><td>
<table class="mainpagetable">
<tr>
<td class="maincontent">
<table class="contenttable" >
<tr><td><div class="contenttop"><span class="newheader">About</span></div>
<div class="contentmiddle" id="contentmiddle">
<table class="newcontent">
<tr><td>
<br>
<?php include 'about.html'; ?>
</td></tr>
</table>
</div>
<div class="contentbottom"></div></td></tr>
</table>
</td>
<td class="gap">
</td>
<?php include '/home/content/69/7232369/html/site_footer.html' ?>
So basically, I created the entire layout in HTML, separating the parts of the site by using tables within tables. I have a PHP include for the header, the page content, and the footer. All of my pages look like this, and it seemed like a good approach at first, however I recently switched to a different host and when I copied everything over, none of the includes for the headers/footers worked because of the different path to the root directory:
<?php include '/home/content/69/7232369/html/loco_header.html' ?>
Which was a pain to go through 100+ php files and change the header/footer include on each of them one by one. It was then that I realized I am probably doing something wrong.
So my questions are:
1) Is there function in PHP that returns the root directory for your website, so that I could do something like include $root . "/header.html" ?
2) My method for creating clean URLs creates quite a bit of extra directories and files. Is there a different recommended approach that I can take which would run smooth and generate less files (while still being search engine friendly)?
3) Is there more efficient/more manageable approach for loading the content into the center of my page, that would also work nicely with a method for having clean URLs (see question #2)? AJAX comes to mind, however I would like there to be an actual URL link to each content page, rather than having everything loaded dynamically in the middle of my home page without the URL changing. I honestly don't know if there is a good solution to this.
4) Is it considered poor practice to use tables within tables for structuring my layout? As you can see, I am splitting up my HTML code in the middle of table tags and placing it in 3 different files (header, index, footer) to structure my site. This seems bad to me.
If it helps to clarify the structure of my pages, here is a link to a page on my site: http://locohq.com/about/
Any help is appreciated, thanks!