Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to format text gathered from MySQL database.

Status
Not open for further replies.

egrant

Programmer
Mar 6, 2003
42
AU
Hi All,

Can someone lead me in the right direction on how to format text coming from a database to be properly displayed on a cgi web page. I used a simple form with a textarea field to send data to my MySQL database. When I view the table through MySql it shows the data correctly formated (ie with carraige returns)

When I display the data I entered via the textarea on the webpage (through a DBI query and an array) it does not format it to look like what is in the database and what I originally entered.

Is there a 'Format' syntax in cgi coding?

Thanks for any replies,

Emma
 
You're going to have to replace your newline characters with <br> for display on HTML.

Alternatively you can use Text::Wrap to wrap the text at a certain column length, and then append a &quot;<br>&quot; to each line

$line =~ s/\\n/<br>/g;

HTH
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
or wrap it in <pre> tags...</pre>

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top