views:

232

answers:

3

Is it possible to create bold text in a MySQL database text table field?

We are putting our articles in our database and I want to create bold titles and subtitles. Is this possible? Thanks

+7  A: 

Markdown

I would advise you to use a markdown-style formatting (PHP/.NET), which would mean bold-text would be stored like this:

**I am bold**

Storing HTML

If you can't use markdown on your project, you can store HTML as well - I would just be very careful about what tags you store. You wouldn't want somebody posting <script/> tags in your database for instance:

<strong>I am bold</strong>

Late-Styling

Or make all values from the title and subtitle fields bold when you print them on your page:

<strong><?php print $row->title; ?></strong>
Jonathan Sampson
+1 If you're using PHP, I'd also heartily recommend using mysql_real_escape_string for all DB operations.
middaparka
I spoke to our developer and we are using mysql_real_escape. I was really hoping to be able to take this task off the table for him and edit bold subtitles directly in the database. But it sounds like that is not possible or the right thing to do..
roacha
Roacha, the *right* thing to do would be to implement a Markdown system (first example), or make your `$row->title` and `$row->subtitle` bold when you're outputting them on your webpage. If you found this answer helpful, please accept it by clicking the check-mark next to it.
Jonathan Sampson
+1  A: 

the bolding should be done after getting the fields from the database. the display of the fields should bold it.

John Boker
A: 

You can add styling information with some sort of markup. If you're using the data in a web application the obvious choice is to use HTML markup.

stimms