I'd like to create some organized web pages using HTML & PHP.
I want to have include files that will be used on the various pages (e.g. header.inc, footer.inc, styles.css, sidenav.inc ...).
I want to know how to put it all together, so that it builds uniformly, up to standards, and works correctly.
How do I construct the body (index.php) page (tables...) to hold these includes? If the body is a table with fields setup to hold the includes, is it ok to have tables in the include files? In other words, if my header.inc contains a multicell table, is it ok to include that into a table field in the body (index.php) - table in table? Or, what is the best way to set this all up?
An example of each element (index.php, header.inc, sidebar.inc...) would be helpful.
Also, what tool do you like best for constructing styles?
Thanks...
B-truE
Layout for building a PHP web page/site...
Moderator: General Moderators
Nested tables work fine - but many web designers have moved on to style positioning attributes for page layout. I'm not totally convinced about that but google around for more info and make up your own mind. It gets tricky only if you want to support older browsers.
An stylesheet atatched to a bunch of html templates is one way to control styles.
It's hard to give you an example of how to combine evrything together but basically I think you're looking for a chain of includes to draw each page. Try experimenting with a "php nav plan" to work out how to do it all with the minimum number of includes (more efficient). What I mean by that is do a kind of flow chart to show which file needs to include which other files.
An stylesheet atatched to a bunch of html templates is one way to control styles.
It's hard to give you an example of how to combine evrything together but basically I think you're looking for a chain of includes to draw each page. Try experimenting with a "php nav plan" to work out how to do it all with the minimum number of includes (more efficient). What I mean by that is do a kind of flow chart to show which file needs to include which other files.
Use require() or include(). Just substitute the included file in place of the code you have in the external file.
Here is a basic example:
Here is a basic example:
Code: Select all
<html>
<head>
<title>Max's Page</title>
</head>
<body bgcolor="#33ccff">
<table border="1" valign="center">
<tr>
<td><? require("./header.inc"); ?></td>
</tr>
<tr>
<td><? require("./body.php"); ?></td>
</tr>
<tr>
<td><? require("./footer.inc"); ?></td>
</tr>
</table>
</body>
</html>header.inc...
I'd like to see an example of the header.inc/footer.inc/body.inc files. I'm concerened about how the tables in those files cooperate with the table in the main index.php file.
Thanks.
B-truE
Thanks.
B-truE
Here's how I'm building a CMS with lots of different functions (forum, articles, claendar etc) as separate "modules".
All pages are included in a single index.php file in the site root. This file processes GET vars and includes a modules/module_name/index.php file which goes something like this:
There's a table for the header, a single row table for the sidebar & main page content (placed in separate cells) and a table for the footer.
This may or not be the best way to do it, but it works for me.
As I mentioned previously, many people use style positioning rather than tables. I don't in part because I want to allow people to easily change page layouts without having any CSS skills.
Incidentally, including everything in a single index.php file (not the module index.php the one in the site root) provides a handy "gateway" to do things like authentication or include common scripts (eg a db connection script).
All pages are included in a single index.php file in the site root. This file processes GET vars and includes a modules/module_name/index.php file which goes something like this:
Code: Select all
<?php
$page_title="Articles";
echo $meta;
// starts html code; all html between <head> tags
echo $head;
// header layout element (a table)
include("html/header_dynamic.htm");
// the page body (single row table)
echo $opentable_mainbody; // fn which starts a table
boxColumn("l"); // sidebar placed in the left table cell
echo $spacer_cell;
// open table cell for main body content
echo '<td align ="left" valign="top">';
// main functions file which will switch case to draw lists, view single items, add items etc
include('modules/articles/main.php');
// close table cell
echo '</td>';
// close table
echo $closetable_mainbody;
// footer layout element (a table)
include("html/footer.htm");
?>This may or not be the best way to do it, but it works for me.
As I mentioned previously, many people use style positioning rather than tables. I don't in part because I want to allow people to easily change page layouts without having any CSS skills.
Incidentally, including everything in a single index.php file (not the module index.php the one in the site root) provides a handy "gateway" to do things like authentication or include common scripts (eg a db connection script).