Solved

Formatting output from a longtext field

Posted on 2007-03-17
5
228 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
  • 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 250 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
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.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

821 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