Over the past little while I have been attempting to code a web site that is dynamic and based mainly on 2 tables in a MySQl db (files, templates). There are others but they are not important for the questions I have.
My first question is: The URLS are encoded using the files_id column in the files table using the variable 'fPath' in the URL (ie: services.php?fPath=1). According to the file_id the pages are created... pretty standard so far. I have checking to make sure that file_is exists and if not to show an 'Item removed' page, of something to the effect. I also have it check to make sure that fPath is set and if not to show a default page. This all works well. The only problem is that all file data for the site is saved in the files table and if someone calls something using services.php?fPath=19 where file_id 19 has nothing to do with services and is set up to call a different template. (I tried adding
// check to make sure the bastards are not typing in random fPath numbers
if ($files_filename == $PHP_SELF) {
etc.... but the script got 'confused)
Two possible solutions I have thought of are add extra encoding to the URL (ie: &category=services) then check that. This didn't alwasy seem to work right. Second solution I thought of, which I want to try and avoid is; create new tables for each section of the site... not something I had planned on.
My other problem is I want all the links to be created, in an organized way from the database. I have categories and sub-categories tied into each file and consequently into each template but I am having problems establishing an effective 'parent - child' relationship between them.
Here are some of the db samples:
CREATE TABLE files (
files_id int(5) NOT NULL auto_increment,
files_template_id int(5) NOT NULL,
files_date_created datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
files_category_id int(5) NOT NULL,
files_last_modified datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
files_type_id int(5) NOT NULL,
files_title varchar(255) NOT NULL,
files_accessReq int(5) NOT NULL,
files_accessMin int(5) NOT NULL,
files_securityLevel int(5) NOT NULL,
files_language varchar(255) NOT NULL,
files_meta varchar(255) NOT NULL,
files_author_id int(5) NOT NULL,
files_description text NOT NULL,
files_right_column varchar(255) NOT NULL,
files_content longtext NOT NULL,
files_filename varchar(255) NOT NULL,
files_default tinyint(1) NOT NULL,
PRIMARY KEY (files_id)
);
CREATE TABLE templates (
template_id int(5) NOT NULL auto_increment,
template_date_created datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
template_header varchar(255) NOT NULL,
template_left_column varchar(255) NOT NULL,
template_footer varchar(255) NOT NULL,
template_last_modified datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
template_stylesheet varchar(255) NOT NULL,
template_description text NOT NULL,
template_name varchar(255) NOT NULL,
template_filename varchar(255) NOT NULL,
PRIMARY KEY (template_id)
);
Everything is based on file_id and the template is created from the template_id,
I hope someone can help/offer suggestions... Thanks for your patience.