Miscellaneous > Programming & Networking
PHP/MySQL question
LorKorub:
I wrote my own guestbook script for a friend's web site I am doing, but I cannot seem to format the text from a textbox to get it to output properly on the "view guestbook" screen. It writes on only one line, and pressing Return, Tab, etc. have no effect.
I tried adjusting the column width on the output table, but no effect either...
Any suggestions?
flap:
You'll need to replace the newline characters in the text with <br>
Master of Reality:
cant you replace it with the php with a /n ?
(i dont know... i am asking)
voidmain:
After pulling my guestbook comments from the database here is what I do to insert a <BR> wherever there is a return:
--- Code: ---
--- End code ---
LorKorub:
Thanks guys...
void: Your function worked, but since PHP 4.0+ they have come up with something much easier to use. It is called the nl2br function. Easy:
<?
$text=mysql_result($blah,$i,"blah");
$new_text=nl2br($text);
?>
Then just call $new_text where you want to use it, or pass whatever variable you want to nl2br and call it directly.
Navigation
[0] Message Index
[#] Next page
Go to full version