Im trying to create a pages table to hold all my web pages content (Stuff between the <body> tags, heres what I have so far...
CREATE TABLE Pages (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
I think this is the best way to go about this (right?)
the Display column is a boolean value (0,1) which will either say to show or not this page.
The Name column is the name given to the page (will also be the pages title)
The Content column is the HTML code which will be between the <body> and </body> tags
Am I on the right track here or is there some sort of tutorial to do this?\
(how do I get HTML code inside Content?)
Well you have the create statement pretty much OK, as far as it goes.
have you thought about the structure of your web pages? as it stands, each of your page 'contents' will have the same tags throughout, which means you have some content stored in many records for no real reason. And then if you decide in the future to adjust an individual page, might that break the others because they would all have the same tags?
How I have done it is this.. (not that I am correct but it works for me and the pharmacist. lol)
I store my images in a set of three tables - images, gallery_titles and gallery_images. So I have a bucket of images and then I decide which gallery they are to be in.
I store my text for each page in a set of tables. file_sequencing, file_data and file_images. Which means I can have several paragraphs stored individually where each may or may not have an image(s). Sequencing is used to sequence them in the nav menu.
So if I change the html tags on any one page it won't affect any other but, at the same time, I haven't stored certain html tags throughout the db which would have to be altered if I redesign the website. (I leaned that the hard way) - pretty much like always.
food for thought. It may not work for you but it might get you rolling a bit further.
further: I don't use the boolean value because I store a start_date and end_date for each file, in file_sequencing. this means I can prepare a site edition in advance and so if end_date is passed, a file won't show. And if the start_date has yet to be reached, the file won't show.
So what to show is managed sort-of-automatically and is determined by the dates. unless an edition has been inputted, which starts after today, the end date of the 'current' file is 0000-00-00. This ensures that in my query, I show only that file which has the latest start_date <= curdate() with end_date > curdate() or 0000-00-00