Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

little html editor with php

Status
Not open for further replies.

leegold2

Technical User
Oct 10, 2004
116
I'm trying to do the following:

Have a textarea in a form, but in the textarea i want to view html source not the html. eg. if there's "&" I want to see "&" and not "&".

What I am trying yo do is make a little html editor in a form's textarea for editing MYSQL fields with PHP. But every time I SELECT a field it shows up as HTML and not html source ( I might have some html in a field along with text).

Thanks
 
When you display the lines, instead of
Code:
echo $str;
use
Code:
echo htmlentities($str);

BTW, it would help if you would post your code that doesn't work.

Ken
 
But what I want is really a text editor inside a form's textarea,

echo '<br><br><h4>Description:</h4><p><textarea name="tp_d" rows="4" cols="72">'.$d_content.'</textarea>';

So I would see html markup and html entities - just like a text editor. I also would want to be able to edit it all just likea text editor - this is done in PHPMyadmin for example...
 
Text inserted in textarea will not be parsed. So if you enter <div> it will show <div> instead of a box. Your problem seems to be data you are trying to input into the textarea. Just try this and see what happens.
Code:
$strHTML = '<div id="header"><img src="pic.gif" width="15" height="15" alt="bullet" /><strong>Hi!</strong><br /></div>';
echo '<form><textarea>' . $strHTML . '</textarea></form>';
Textarea should show code as is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top