bigrossco Posted January 3, 2007 Share Posted January 3, 2007 is their anyway i can have brakes added in to the type "text" so when results in that field are shown in php with brakes?Ross Quote Link to comment https://forums.phpfreaks.com/topic/32705-adding-brakes-in-text-type/ Share on other sites More sharing options...
obsidian Posted January 3, 2007 Share Posted January 3, 2007 The best way I know of (depending on how your text is getting populated), assuming you're using a textarea, is just to leave the line breaks the user inputs as-is. Then, when you output the record to the screen, run the nl2br() function on the string, and it will convert all the line breaks to <br /> tags to display properly. Quote Link to comment https://forums.phpfreaks.com/topic/32705-adding-brakes-in-text-type/#findComment-152205 Share on other sites More sharing options...
bigrossco Posted January 3, 2007 Author Share Posted January 3, 2007 how would i run the nl2br() Quote Link to comment https://forums.phpfreaks.com/topic/32705-adding-brakes-in-text-type/#findComment-152214 Share on other sites More sharing options...
obsidian Posted January 3, 2007 Share Posted January 3, 2007 Hopefully this will make more sense:[code]<?php// Let's say I'm pulling comments out of my database:$sql = mysql_query("SELECT name, email, comment FROM comments");while ($x = mysql_fetch_array($sql)) { $from = "<a href=\"mailto:{$x['email']}\">{$x['name']}</a>"; $note = nl2br($x['comment']); // This will interpret all my line breaks for me // Now, you can display it however you like.}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32705-adding-brakes-in-text-type/#findComment-152265 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.