![]() |
Line breaks? When pulling from the Database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Line breaks? When pulling from the Database (/showthread.php?tid=23300) |
Line breaks? When pulling from the Database - El Forum - 10-06-2009 [eluser]JamieBarton[/eluser] Hey guys, I'm doing sort of a news system, what is the best way to perform line beaks. My articles in the DB have line breaks, however, when i load the view (below) everything is crammed together. How can I get round this? controller: Code: function article() view: Code: <div id="main"> Regards, Jamie Line breaks? When pulling from the Database - El Forum - 10-06-2009 [eluser]imn.codeartist[/eluser] If your line break is \n then use the below code Code: <p><? echo nl2br($row->body)?></p> Line breaks? When pulling from the Database - El Forum - 10-06-2009 [eluser]BrianDHall[/eluser] You could try replacing "\n" (newline) with <br>. It's the easiest way I know of. EDIT: dixcoder beat me to it. Also, there is always the <pre> HTML tag. |