[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

echo doesn't render <textarea> wording as it was entered in a form with space between paragrahs, etc.

Posted on 2011-04-26
4
Medium Priority
?
277 Views
Last Modified: 2013-12-12
Hello Experts:

I can see new lines in mysql, but when I echo the wording, every line runs together.  

Here's my code:
<div id="copy"><?php echo $row_Recordset1['Copy']; ?></div>

Thank you, help is appreciated.

0
Comment
Question by:comprows
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Greg Alexander
ID: 35472223
This may do it for you

<div id="copy"><?php echo nl2br($row_Recordset1['Copy']); ?></div>

Open in new window

0
 

Author Comment

by:comprows
ID: 35472384
That didn't work for me, but that might be because there isn't a \nl in the copy.  There is space between paragraphs though.  You can see it here in the copy shown below from the text area:

Daily, Weekly or Monthly Specials
You can enter your special AskNRD promotion in
this location at any time.

<a href="../advertising.php">Advertising Info</a>
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 35472417
try adding a white-space:pre rule in your css:
<head>
<style type="text/css">
#copy{white-space:pre;}
</style>
</head>
<body>
...
<div id="copy" style="white-space:pre;"><?php echo htmlentities($row_Recordset1['Copy'], ENT_QUOTES); ?></div>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:comprows
ID: 35472536
Thanks to both Experts!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month20 days, 1 hour left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question