Solved

Locking table

Posted on 2003-11-18
4
384 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
  • 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
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.
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 …

708 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

15 Experts available now in Live!

Get 1:1 Help Now