Solved

Locking table

Posted on 2003-11-18
4
389 Views
Last Modified: 2013-12-13
I had successfull when inserting/viewing longtext data format from/in to mySQL database.
But i had a problem when viewing it in html table.
-No paragraph, write in 1 line only without braked line.
-The table width pushed by the text, then the table to be wider. (My page design damaged by that)

My question is :
1. How to locking the table width, so the text will automatically break lined ?
Inserting "<br>" text when inputting data in form textarea annoying me.
So, give me other solution.

2. How to prevent someone to not inserting html code to textarea form ?
Then, all text will be converted to text format.

I use this html form to send one paragraph of text :
<textarea name=news rows=60 cols=100%></textarea>

I use this php code to viewing $news :
print("<table width=50% border=0 cellpadding=0 cellspacing=0><tr><td>");
print("$news \n");
print("</td></tr></table>");
0
Comment
Question by:shanyuen
[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
4 Comments
 
LVL 1

Expert Comment

by:penguin3
ID: 9890115
Not sure what you mean by locking the table but under normal usage of text field I guess this line will solve both your problems if put before your print lines.
$news  = nl2br(htmlentities($news ));
0
 
LVL 5

Author Comment

by:shanyuen
ID: 9894631
Only question number 2 answered by that method.

This is what i means about my question (to locking table width) :

My client inserting 1 paragraph of text (many sentences) to text area form WITHOUT pressing enter button.

Then, NO new line created.

You know that my table width is 50%, long sentences (without new line) will stretching the table.

I had try this, but does'nt work.

print("<P>$news</P>");

  or

print("<PRE>$news</PRE>");

0
 
LVL 1

Accepted Solution

by:
penguin3 earned 250 total points
ID: 9896517
I see.
Normally when posting to MySQL the linebrakes are in fact inserted but as \r\n and the nl2br-funcion converts them to <br />.
You can force a linebreak after a certain number och characters with the wordwrap function.

$news  = htmlentities($news);
$news = wordwrap($news, 50, "<br />");
0
 
LVL 5

Author Comment

by:shanyuen
ID: 9897814
It's work.
Thank You Very Much 100000x...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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 …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

739 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