Jump to content

one index.php for all the pages???


sili

Recommended Posts

Hi Guys. I am starting to make a webpage in html but it confuses me a lot having a lot of .html pages and always managing the links, changhing the names in each page, if you modify something you have to go at every single page and change it + it slowly is killing my brain  by looking at those pages.

Someone told me that you don't have to struggle a lot and if I would have used php I would have a single index.php file and put all those files in that file. So at the end I would have ended up with only one big file.

I was just wondering if it is doable and please can you explain how. thank you....

Link to comment
https://forums.phpfreaks.com/topic/38870-one-indexphp-for-all-the-pages/
Share on other sites

I think your looking for something like this??

 

< start of page >

<standard header on every page>

 

<body content >

 

<footer on every page>

 

 

I use this method.

 

header.php


<html >
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="50" colspan="2"><h1 align="center">Header</h1></td>
  </tr>
  <tr> 
    <td width="10%">Navigation</td>
    <td width="90%" align="center">

   <!--All your pages will load here.-->


<?php function footer(){ ?>	
</td>
  </tr>
  <tr> 
    <td height="20" colspan="2">Footer</td>
  </tr>
</table>
</body>
</html>
<?php } ?>

 

Then on each page you want this to show up, use <?php include('path/to/header.php') ?> at the top, and at the bottom, call <?php footer(); ?>. This pulls the header.php file into each page, and simply wraps each file in the top part and the footer function.

 

This can be applied to a horizontal nav by changing the table structure. I imagine it could work with a css div style layout as well.

 

 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.