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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display CODE! from a mysql database on the page 1

Status
Not open for further replies.

lukelukeluke

Technical User
Dec 23, 2003
117
0
0
CH
Hi everyone.
I've done a little knowledgebase in php/mysql. Now i would like to have code like this: <html><body><?php ?> and stuff inside my database and when i print it out, it should be displayed. I mean i want to enter things like this with php: >, <
and want it to be stored into database like this:
&gt;, &lt;
It would be cool if someone has a solution to do that with all codes or with all |{]Ç[Ç{}?|}¿{|[|{[# to have them into the database so they can be displayed after...

thanks for your ideas
 
why not strip them using javacript escape/unescape functions....

Known is handfull, Unknown is worldfull
 
PHP offers 2 specific functions to convert characters to HTML entities:
They translate a smaller/larget set od characters into the appropriate HTML entites.
Also, when you display content like yours consider the use of the <pre> tags to keep whitespace formatting.
 
htmlentities() worked very fine, thanks.

Now, how could i build something like the function of tektips, where you can enter a
Code:
....
and it creates you a div?

ideas?
thanks...
 
use regex or string_replace() to replace certain characters with something else

ie
Code:
$divcode = "<div id='mydiv'>";

$html .= str_replace("....",$divcode,$myhtmlinput);


Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top