putting preformatted text in mysql

I have a form field that collects an artists biographical information. This then appears on the artists web page. Often the text has certain bolded areas, underlinings, etc.

I would like the user filling out the form to be able to copy and paste there bio info into the form field and retain the formatting when it is stored in the db and output to the artist's page.

However on the artists website page, the artist bio needs to fit into a space about 190 pixels wide.

Basically I would like the text to retain the formatting (any bold text, underlines, line breaks,etc) that the user pastes into the form field and also conform to the width dimension listed above - to keep the look of the artist page consistent.

The less code the better if possible...thanks
dblackerAsked:
Who is Participating?
 
minichickenConnect With a Mentor Commented:
I've tried it before, it not that difficult to integrate, and ofcoz you can customize it according to your needs.
Maybe you should go try out the demo at http://www.dynarch.com/demos/htmlarea/examples/core.html and do a copy and paste to check if its the result that you want.
0
 
hernst42Commented:
You can suround the text with a div -tag:

<div style="width:190px;"><?=$text?></div>

This puts the text into 190pixel column
0
 
minichickenCommented:
Are you looking for a rich text box, so you can save the text in HTML format in the DB?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
dblackerAuthor Commented:
maybe...just looking for a way for the user to copy and paste preformatted text - have it saved as such in db - then appear on artist page with all preformatting...
0
 
minichickenCommented:
If you are looking for a WYSIWYG HTML editor or text box.
You should take a look at http://www.dynarch.com/projects/htmlarea/ (I think it' free) and http://www.blueshoes.org/en/javascript/editor/ (don't think it's free)

What you can do with this WYSIWYG editor is that, the user can preformat his/her text in that text box. When you posts the values to your PHP page to be inserted into the DB, that passed value will be the HTML code (for bold, italics text, etc...).

If you are passing HTML code with HTML special characters to the DB, remember to use the htmlspecialchars(); function to prevent any output errors while retrieving the text from the DB.

regards

j311y :)
0
 
dblackerAuthor Commented:
thanks for the links - that would work but is an added step i would prefer to avoid. the average user may not be that web savvy and i would, if possible, just make them copy and paste...
0
 
minichickenCommented:
I think the one from http://www.dynarch.com/projects/htmlarea/ will be useful if you want the user to copy and paste HTML formated text. When you do a copy and paste, it will paste the exact format (bold, italics, etc....) except for the CSS style.
0
 
dblackerAuthor Commented:
This very text box in which i am writing now will format the line breaks that i create when i hit the enter. Knowing how to do this would be a good start...
0
 
minichickenCommented:
Good start.... anyways hope you did find the links to the textbox and the demo useful for you or added some value to your question :)
0
 
dblackerAuthor Commented:
but i don't know how to achieve the results that this textarea box does...i was saying if someone knew how to get the line breaks when you hit enter i would really like to know that?




like this line is way down here -


0
 
dblackerAuthor Commented:
wait got the line break thing --> $artist_bio =  nl2br($artist_bio);
0
 
minichickenCommented:
Hi dblacker

No offence or anything, may I know why you dont want to just incorporate HTMLAREA WYSISYG from http://www.dynarch.com and re-invent the wheel? Is that not what you looking for?

regards
0
 
dblackerAuthor Commented:
well it's pretty good but it seems it's only compatable with explorer 5.5 and above which might preclude some people. I was trying to find out another way to design the input form so that I could be more specific with the format and just get around this whole thing all together .

As for dynarch does it need to be installed on each persons computer that fills out the form or is the formatting done online - the latter case would be better becuase i'm trying to avoid the user having to download the software - install it - etc.

I think it is a good suggestion ijust don't know if i'm complicating things...
0
 
minichickenCommented:
The user dont need to install that HTMLAREA from dynarch on their machine, you only need to have it on your web server, it works just like a normal textbox just that it accepts preformatted HTML code. So the user does not require to download, he/she can do the formatting online in that rich text box, just like you wanted. It WYSIWYG which makes it very user friendly.

Download it at: http://prdownloads.sourceforge.net/itools-htmlarea/HTMLArea-3.0-rc1.zip?download

I don't know if it works with older browser version, as I couldnt test that, I did however test it on Netscape 7 and IE6 and it works fine.

I really think it a very good tool, and can save you alot of time, if I understand your question corrrectly.

regards

j311y
0
 
nicholassolutionsConnect With a Mentor Commented:
Try this: store the text input by the user as a string in the database (including all line breaks as-is). When you pull the text out, surround it by <pre> tags:

<pre>
user inputted text
</pre>

One word of caution: This allows users to do some potentially VERY annoying stuff, so you should try to do some checks on the input text before just blindly putting it in the db. For example, check to make sure the input string is shorter than some threshold value to make sure they did not dump in 1MB of text. More importantly, make sure they did not enter 100 line breaks in a row...It could be a real pain in the neck if someone does something like this....







....except 100 times. And of course, make sure you strip out HTML...a lot of this has to do with how much you will trust your users, but it's always a good idea NOT to and then work from there, because there are a lot of jerks out there ;)

Cheers
0
 
nicholassolutionsCommented:
....Just to clarify, my solution will not retain bold/underlining, but it will retain layout. One thing that a lot of online forums do to allow people to do formatting is to make custom 'tags' that get translated to html by your script. For example, you might telll users, if you want bold text, do this

[bold] bold text [plain] normal text

and then translate every [bold] into a </b> tag or whatever. Unless you do something like minichicken is suggesting, the user will have to do at least some work to translate something from rich text to HTML.

Cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.