Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Formatting output from a longtext field

Posted on 2007-03-17
5
Medium Priority
?
247 Views
Last Modified: 2012-05-05
Experts,

I have a column within my database message table, which is a longtext field.  This is used to store messages that the user has sent to me.

I need to know how to format the output so that it includes the new rows, when the user has pressed the "enter" key.

0
Comment
Question by:mhouldridge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:mhouldridge
ID: 18740327
I have now;

<? echo "<font class=\"text11\"><pre>".$formVars['message']."</pre></font>"; ?>

This includes the formatting, however the length of the question pushes the table out to the full screen.  I have specified the length of 500px, however it still pushes it out.
0
 

Author Comment

by:mhouldridge
ID: 18740383
Ah, ive got it;

<? echo nl2br("<font class=\"text11\">".$formVars['message']."</font>"); ?>
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18740729
Did you answer this yourself then or did you still have a question?  Let me know if I can help still but it seems like you found the "magic" function. :)

By the way, the font tag is deprecated (losing support).  I suggest using <p>, <div> or another tag.

bol
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18740739
Actually, the best place to use the nl2br function would be ...

<? echo '<font class="text11">' . nl2br($formVars['message']) . '</font>'; ?>

Let me know if you have a question.

bol
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 1000 total points
ID: 18742783
You probablywant to add some htmlspecialchars as well:

<font class="text11">
<?php
  echo nl2br(htmlspecialchars($formVars['message']));
?>
</font>

You also might to think about changing your <font>-tag into a <span> tag, as font tag's are deprecated.

Kind regards

-r-
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

704 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