Question about WYSIWYG

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ScOrPi
Forum Commoner
Posts: 44
Joined: Fri Jul 09, 2010 8:01 am
Location: BAGHDAD - IRAQ

Question about WYSIWYG

Post by ScOrPi »

Hello all ,

i wondering about making WYSIWYG reply box

is it possible to make reply box by using php ?

and what is the basics ?

if it's not possible .. how can i make new line useing text area when i insert it into table

i need to insert <br> when the member press enter key without see it ..
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Question about WYSIWYG

Post by Christopher »

There are a number of rich text editors. CKEditor and TinyMCE are two good and popular ones. Take a look at those.

If you want to use PHP then you need to convert "<br/>" to "\n" after you read the data, display the data in a textarea, and then convert "\n" back to "<br/>" before you save the data.
(#10850)
ScOrPi
Forum Commoner
Posts: 44
Joined: Fri Jul 09, 2010 8:01 am
Location: BAGHDAD - IRAQ

Re: Question about WYSIWYG

Post by ScOrPi »

thanks for reply ..

the question is .. how can i tell php that this is a new line if the member using textarea and he had type something like this
" Hi all

How are u

i hope u r fine "
between every line there is an empty line

if i called textarea topic then

Code: Select all

$topic = $_POST['topic']; /// that would make the topic in on line .. not in differ lines 
so how could i know that it's a new line .. and insert <br>

:banghead:
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: Question about WYSIWYG

Post by jraede »

If you want to use PHP then you need to convert "<br/>" to "\n" after you read the data, display the data in a textarea, and then convert "\n" back to "<br/>" before you save the data.
\n is a special character for line breaks.
User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: Question about WYSIWYG

Post by PHPHorizons »

To be a bit more specific, what the user sees when they type into a textbox is different from the characters that are actually there. Pressing the enter key actually causes a NEW LINE character to be placed into the string: \n
But, the user only sees a new line. Therefore, you can search for \n and replace with <br>

In other words, here is what that string looks like to the computer:
" Hi all\n\nHow are u\n\ni hope u r fine "
Make sense?
ScOrPi
Forum Commoner
Posts: 44
Joined: Fri Jul 09, 2010 8:01 am
Location: BAGHDAD - IRAQ

Re: Question about WYSIWYG

Post by ScOrPi »

PHPHorizons wrote:To be a bit more specific, what the user sees when they type into a textbox is different from the characters that are actually there. Pressing the enter key actually causes a NEW LINE character to be placed into the string: \n
But, the user only sees a new line. Therefore, you can search for \n and replace with <br>

In other words, here is what that string looks like to the computer:
" Hi all\n\nHow are u\n\ni hope u r fine "
Make sense?
ahaa ... i got it ..

u r genius thank you so much .
User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: Question about WYSIWYG

Post by PHPHorizons »

You're welcome ;)
Post Reply