PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
lloydsmods
Forum Newbie
Posts: 22 Joined: Wed Aug 14, 2002 2:03 pm
Location: NC
Post
by lloydsmods » Mon Oct 28, 2002 6:21 pm
How do you execute a line break without resorting to the HTML tag <br>?
I've tried "\n" but that doesn't seem to work. It still strings the records together into one big line.
I need to output data from my MySQL database but I need each record to be on its own line and I can't use HTML.
Any suggestions?
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Mon Oct 28, 2002 6:34 pm
<pre>text</pre> will preserve \n-linebreaks (pre-formatted)
nl2br() is also an option
Tiimmy
Forum Commoner
Posts: 38 Joined: Sat Apr 27, 2002 1:56 am
Location: Australia
Contact:
Post
by Tiimmy » Mon Oct 28, 2002 7:44 pm
The problem with
\n that you could be having might be because you're using
echo() , if you are; you'll need to use
print() instead.
Code: Select all
<?php
echo "Hello world\n"; // Won't work.
print "Hello world\n"; // Will work.
?>
lc
Forum Contributor
Posts: 188 Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands
Post
by lc » Mon Oct 28, 2002 8:12 pm
Depending on your system.... you may want to try \r\n in stead of just \n that solved it for me on windoze systems.
sam
Forum Contributor
Posts: 217 Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:
Post
by sam » Mon Oct 28, 2002 11:45 pm
Tiimmy the \n char should work with both echo and print, I just tested it with php 4.2.1,4.2.2 and 4.3RC2 on windows and 4.2.1 on redhat unix and it worked the same on all three.
Takuma
Forum Regular
Posts: 931 Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:
Post
by Takuma » Tue Oct 29, 2002 1:35 am
How can you execute a line break?
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Oct 29, 2002 2:42 am
Why can't you use HTML?
Mac