Solved

Formatting output from a longtext field

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

627 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