Web Hosting Talk







View Full Version : How do I do this?


MMD
08-29-2002, 09:01 AM
How do I do this? :)

http://www.static-pulse.co.uk/etcetcetc.gif

When the text comes out on the PHP page it doesn't have line breaks, how do I code the add_news page to see new lines as line breaks?

thx in advance :)

shaunewing
08-29-2002, 09:19 AM
You want to look into the nl2br function which was mentioned on this thread (http://www.webhostingtalk.com/showthread.php?s=&threadid=70618).

As an example on usage, say your text with the line breaks is stored in $txtMessage.

Instead of something like:

echo $txtMessage;
you'll do:
echo nl2br($txtMessage);

I hope that helps.

--Shaun

AC1
08-29-2002, 09:21 AM
Hi

Use the HTML <br> command:

etc <br>
etc <br>
etc <br>

Or if you want the data you are writing in paragraphs you can enclose it in a paragraph as follows.

<p> etc </p>
<p> etc </p>

I hope this helps.

Andy

shaunewing
08-29-2002, 09:24 AM
Yes, you could also do what Andy mentioned.

It depends how you want to go about it.

If you want to have the person entering the news add the <br /> (or <br> tags) manually then use Andy's method. If you want the <br /> tags to be added behind the scenes, then use the method I explained.

This assumes that you wrote the script being used and know how to modify it. If you didn't, let me know the script name and I may be able to get it and provide a few pointers.

Regards,
Shaun

MMD
08-29-2002, 09:40 AM
spot on shaunewing! :)

I just replaced:
<?php echo stripslashes($row[3]); ?>
with
<?php echo stripslashes(nl2br($row[3])); ?>

and it worked great :)
Thanks very much!

shaunewing
08-29-2002, 09:53 AM
Originally posted by MMD
spot on shaunewing! :)

I just replaced:
<?php echo stripslashes($row[3]); ?>
with
<?php echo stripslashes(nl2br($row[3])); ?>

and it worked great :)
Thanks very much!

Glad to be a help! :)

--Shaun