Solved

Formatting output from a longtext field

Posted on 2007-03-17
5
225 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 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 …

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now