views:

23

answers:

2

I understand the part of inserting data in the database for creating a database driven user content website but how to do formatting? Say i insert the "Privacy policy" Now some text may require to be bold, some may be underline, some may have different size, spacing, etc. So do we have to insert each word 1 by 1 or how to handle this? Using php/mysql for my site.

+1  A: 

Store your text in the database with the html markup included so you can just display it directly with no processing needed. Or, if necessary, you could store it as xml and use xslt to process it for display.

Ray
I have multi language also, so hence storing in DB and not using XML.
drk001
I would suggest storing each language version in the db with the html formatting included - you would need an extra column in the table to specify the language in the current record. I don't see any other way, unless you can convert to xml and xslt (which is not trivial if you are not familiar with it).
Ray
@drk001: Ray's point is to store HTML or XML in the database. The DB doesn't know or chare what the content of a varchar field means. You can put any markup in there you like.
Jay
A: 

You could also do things the way stackoverflow does them : have users enter their content free form (or close to it) and use Markdown to format the page content when it's rendered to the user. That way you could have your formatting and store multiple versions of pages in different languages.

Alex Marshall