Jump to content

Recommended Posts

Hello

 

i m trying to build my own blog. I am almost done. But the problem is, i designed a blog-enty-page, and when i write at textarea and post it ( cause there is no "<br>" tags when i press enter for the newline, ) it does not seem good and everytime i open the post and add all tags manually. But at wordpress ( and here when i m posting this entry )  when you enter it automatically adds br tag to the text. How can i do it ? Do they use javascript ? Is there any free-to-use panels on web ? How do you solve this problem ? I m sure when you post something you have to add some tags for br or italic etc.

 

Thank you in advance for your answer.

Link to comment
https://forums.phpfreaks.com/topic/137976-solved-how-do-you-do-this/
Share on other sites

Don't worry about any JavaScript. What your doing is fine, all it's doing is storing it as a \n or \r\n depending on the OS.

 

All you need to do is retrieve the text from SQL and use the nl2br function to convert all new line characters to line breaks.

Don't worry about any JavaScript. What your doing is fine, all it's doing is storing it as a \n or \r\n depending on the OS.

 

All you need to do is retrieve the text from SQL and use the nl2br function to convert all new line characters to line breaks.

Thank you for your reply ProjectFear

 

But then, I think I should write "\n or \r\n" instead of "<br>" while posting the entry ?? And i want to use "italic" "bold" etc. ? At that time can i use them ?

Yes, look into bbcode for STYLING the text but as for new lines. If they hit enter in a text area field and then submit that data and you store it in a MySQL table, then when you retrieve that value back from the table all you need is nl2br.

 

For other tags, such as italic you can look at simple str_replace tutorials.

i got the bbcode part but how can i do that like WYSIWYG style. I mean I want to make the text bold when the user select the text and click the "make it bold" button. I think i need to learn some javascript, dont i ? Or can i find ready-to-use script ? How do you solve this problem ? Do you code it yourself ?

i got the bbcode part but how can i do that like WYSIWYG style. I mean I want to make the text bold when the user select the text and click the "make it bold" button. I think i need to learn some javascript, dont i ? Or can i find ready-to-use script ? How do you solve this problem ? Do you code it yourself ?

For a WYSIWYG editor, take a look at FckEdit or TinyMCE

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.