PHP: newline character doesn't work?


I have this:

while ($row = mysql_fetch_object($result)){
echo "$row->photo_filename
echo "$row->photo_caption
echo "$row->photo_security";

So I want the 3 fields displayed on 3 different lines. Except that the newline character doesn’t seem to work. Am I doing something wrong with the newline character?

Thanks in advance! :slight_smile:

I would recommend using <br /> isntead of
. I guess
only works when using file editiing

Actually, it is working. If you right click and view source, you will see that they are on seperate lines. To make it actually appear like that though, you have to do what Hamza said and do <br> or I guess the proper way is <br />

You lost me there. I think the reason why they are on seperate lines when viewing the source is because I entered the code that way… pressing enter after each line. It’s just that when echo-ing this on a HTML page, it displays everything on one line.

Thank you both for the <br> tip. What is <br />?

BR is a hard return in HTML. The
is a hard return in the source. Try it out - if you just leave out all the
’s and look at your HTML source, you’ll see that it’s all on one line. PHP is printing the source code of your HTML file - therefore a
will become a newline in the source code. A <br/> (XHTML strict version of <br>) in the source code of a HTML file will result in a newline on the HTML page, but a newline in the source code won’t.

I understand now. And thanks for the <br/> explaination as well. It works now. :slight_smile:

Anytime :slight_smile: