I have stored rich text in my db, and now I would like to show it to the website viewers, but when I echo the content I got this:
<p>sometext</p><strong>text</strong>
I would like to remove the 'P' tags and any other tags from the text.
I have used Ckeditor to store the rich text into DB.
I could use Ckeditor to show the rich text to the website viewers, but Ckeditor is an editor and I would like only to show the rich text.
Is there any in-built php command to convert the stored text into rich text and display it on my website?
My Answer:
It seems like the rich text content you stored in your database is not being displayed properly on your website. This could be due to the way you are retrieving and displaying the content.
To properly display rich text content from your database in a website, you can use JavaScript to fetch the content from the database and then insert it into the HTML document using innerHTML property.
Here is an example code snippet that demonstrates how you can fetch and display rich text content from your database using JavaScript:
javascript
// Assuming you have a div element with id "rich-text-content" where you want to display the content
const richTextContent = document.getElementById("rich-text-content");
// Fetch the rich text content from your database (you can use AJAX or fetch API)
// For demonstration purposes, let's assume you have the content stored in a variable called "dbRichTextContent"
const dbRichTextContent = "This is some rich text content from the database
";
// Set the innerHTML of the div element to display the rich text content
richTextContent.innerHTML = dbRichTextContent;
Make sure to replace `dbRichTextContent` with the actual content you retrieve from your database. This code snippet will insert the rich text content into the specified div element on your website.
If you are still facing issues with displaying the rich text content, please provide more details or code snippets for further assistance.
Rate this post
5 of 5 based on 1484 votesComments