Here's the 10 cent tour of templates. First, make a template page that sorta kinda looks how you want your site. Then, break it up into logical pieces, so you have something like this:
index.html:
include "header.inc";
include "body.inc";
include "footer.inc";
body.inc:
include "some db connection class";
$res = query ($conn,"select body from filedata where id = '$id'");
$data = fetch_array($res,0);
print $data['body'];
This is the simplest type of thing. note that in body.inc I have non working commands on purpose, as you might use a different db or db class than I do. but it translates pretty well.