Database storing text for web site - Formatting/Layout Issues

What is the best way to use a database to store text for the web pages?

Obviously, if I create one field for all text about a product I am going to find it impossible to format! I would not be about to set sub headings to Bold, add bullet points to a list of features, move a line of descriptive text to appear beneath an image explaining what it is, etc.

So the natural suggestion would be add more fields. One for the text below images, another field for bold sub headings and I could end up with alot of fields in my database.

The problem I have is not all page content/page formatting will be identical. So whereas one page may have a Heading, then a paragraph of text, then bullet points, then a subheading. Another web page may have a Heading, then bullet points, then a paragraph of text, etc…

This could mean having many, many fields!!! I could then fill in the data in the database and create the design by leaving some fields empty. This is illustrated below whereby I have field names and I leave blank the 3 of the 4 I do not need. The below example would be a page that had: Heading,then paragraph of text, then bullet points, then another paragraph of text.

1Heading - Data Enterer
1Paragraph - Left empty
1Bulletpoints - Left empty
1Sub heading - Left empty
2Heading - Left empty
2Paragraph - Data Enterer
2Bulletpoints - Left empty
2Sub heading - Left empty
3Heading - Left empty
3Paragraph - Left empty
3Bulletpoints - Data Enterer
3Sub heading - Left empty
4Heading - Left empty
4Paragraph - Data Enterer
4Bulletpoints - Left empty
4Sub heading - Left empty

This way of designing would mean a very large database and I would be surprised if this was common practice when using MySQL and PHP.

Any suggestions would be considered.

Thanks,

Matt.

one row per page

you have already concluded that it will be necessary to store markup

then you say

The problem I have is not all page content/page formatting will be identical. So whereas one page may have a Heading, then a paragraph of text, then bullet points, then a subheading. Another web page may have a Heading, then bullet points, then a paragraph of text, etc…
the obvious answer is that separate pages get separate rows from the content table

the actual content is just one column

You say the actual content is just one column. But the way I am considering involves many, many fields. Do you not see a problem with this?

of course i see a problem with it

why would you create many, many fields when it’s so much easier just to have one content value per page?

I am not sure what you mean when you say ‘one content value per page.’

My problem is formatting/organising the layout with using a single field.

Matt.

take web page 1, and store the contents of that page in a row in this table –

CREATE TABLE webpages
( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT
, pagename VARCHAR(255) NOT NULL
, title VARCHAR(255) NOT NULL
, author VARCHAR(37)
, descr VARCHAR(255)
, url VARCHAR(255)
, added DATETIME
, chged DATETIME
, contents TEXT
)

then store the contents for web page 2 in a second row

then store the contents for web page 3 in a third row, and so on

each web page has its own content

that content includes markup

I see where I misunderstood. I was going to just include plain text. You are suggesting HTML included in the content field.

The problem is this does not make the site very dynamic. But I suppose your reasoning would be that it would not change much??!?

I could include price, whether it is in stock… (variables that do change regularly) as separate fields then add the content as HTML. I think this is what you are suggesting?

Matt.

yup, something like that

if each page is for a product, then yes, the database table ~would~ have multiple columns – but this assumes that each product page is fairly static

if you have multiple pages that can show the same product, then you would want two tables, one for the product data (invariant), and multiple pages (in a one-to-many relationship) for the various product display pages, and yes, these would likely include the html

the thing to remember is that the “multiples” should be accomplished by rows, not by columns

I was keen to design a site that would only require simple text entry into a database. Is there any method that could achieve this?

If I use HTML it will not be as quick and simple as

  1. get the text I want written
  2. paste it in a database
  3. upload, load in browser

Do you know if many designers achieve this? I imagine it would be a good way for companies whom dont want to pay the running costs of a web designer - far cheaper to just have a login for access to the database and then paste the text in the forms provided/designed?!?

Also, I was a bit unclear on the ‘multiple pages that show the same product’ — I do intend to have multiple pages for the same product but the product name will change slightly. For example, if you were designing a page for the iPhone4 home charger, this is the same charger as for the iPhone3 but obviously wherever it says on the page “designed to charge your iPhone4” needs changing to “designed to charge your iPhone3” — if you werent referring to this issue then not to worry but otherwise can you explain more?

Matt.

regarding simple text entry, i’m sure you could achieve quite a bit just by using something like editize (note the sidebar on the right which refers to a tutorial right here on sitepoint!)

regarding the iphone4/iphone3 charger, if it were me, i would have just the one page, and call it the “iphone charger” and then in the text explain how it could be used for both

it almost sounds like you’re wanting to let seo considerations dictate the proliferation of web pages :slight_smile:

I’ll take a look at editize.

Yes — I do like to maximise search results rather than have a simple web site. If I maximise visitors it can only be a good thing.

MatthewBOnline,

It sounds like we have a similar situation. I have a product “results” page with a Detail page.

However, the issue that I’m dealing with is that I have manufacturing software that connects to a SQL database. However, the people managing this data can’t enter html or and sort of formatting because they simply can’t be expected to learn it. Additionally, the software doesn’t present any way of formatting text in the program. Consequently, since this is the “source” that everything pulls from (Web too), if I want to format text, I need every field that has a unique format to have it’s own column.

But then, what do I do about blocks of <ul> (bullets)? Should I comma separate them? Should I use embedded characters and pull them out and replace them when I want to publish to the web?

Anyways, if anyone has a suggestion on where I can start to look, please help me out. Thanks.

I wish I could find a good place that would explain the options and then explain how to implement this strategy.

I can’t even get a good idea what my options are, let alone how to accomplish it.