Hi guys,
How to keep styled and formated text in db and retrieve it?
My CMS has an "insert post" option. Where a title, a text and a picture can be inserted.
All this is inserted in databaSe, AND is retrieved in the home page.
The text just appears as simple text, no formating. all spaces and line breaks are ignored.
I tried installing a Rich text editor and name all the textareas after it but it was a failed attempt.
so I want to be able to insert html text.
for example.
<h2>Winter Party</h2>
<br>
<br>
<p style="color:red">Don' miss it!!!</p>
<p>some text some text some text, some text <u>some</u> text
<br>
some text.......
</p>
I heard that it's also possible to actually store "PHP" script inside a database table.
I tried to change the field type to "mediumblob" no success!, if i insert any php code in the textarea, all the text
disapears, and for the html, is just not doing anything.
Any help please,
Many thanks i advance,
Mike
Insert and retrieved html and css formated text in Database
Moderator: General Moderators
-
MikeSpider
- Forum Commoner
- Posts: 25
- Joined: Sat Oct 22, 2011 6:45 pm
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Insert and retrieved html and css formated text in Datab
When you say "My CMS" is it one you created? I think it's common practice for a CMS to have a field for each of the options and then style them on display and not to store them "styled".MikeSpider wrote:Where a title, a text and a picture can be inserted.
Code: Select all
<?php
// data retrieved, ready to echo
$title = '<h1>' . $row['title'] . '</h1>';
$text = '<p>' . $row['text']. '</p>';
$picture = '<img src="' . $row['picture'] . '" />';
?>http://php.net/manual/en/function.strip-tags.php
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering