?
Solved

Locking table

Posted on 2003-11-18
4
Medium Priority
?
391 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 1000 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

Independent Software Vendors: 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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
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 …
Suggested Courses

718 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