View Full Version : In need of serious help(php and text areas)

05-02-2004, 01:59 PM

im currently designing a website where the user, once registered can post his or her news on the front page. To accomplish this i made a text area where it will store the string in a php variable named $news once the user hit submits. Heres my problem.

For testing purposes i just hit the letter T until two rows of t's are made in the text area. The problem is, on the table where i display the message(which is the same size as the textarea) it only dispalys one row(it will combine the two rows of T's by readjusting the table.

So basically what i want to have happen is the structure the user has in the text area should be maintained when it is displayed simular to how these forums work.
1.Evaluating the text area and textboxes

$nd=date("l F dS Y h:i a");
mysql_query("INSERT INTO newstories (topic,message,author,date,gametype) VALUES ('$nt','$nm','$na','$nd','$ng')");
echo"<font color=\"white\">News sucessfully updated<br></font><br>";

2.Display code
$query = "SELECT * FROM newstories order by id DESC LIMIT 10";
$result = mysql_query($query,$db);
echo "<TABLE style=\"table-layout:fixed\" style=\"color:white\" border=\"0\" cellspacing=\"0\" width=\"100%\">";
echo "<TR>";
echo"<TD width=\"100%\">";
echo "<table style=\"color: white\" border=\"1\" bordercolor=\"#00ffff\" cellspacing=\"0\" width=\"100%\">";
echo"<td BGCOLOR=\"#0096B8\" ><font color=white>Subject:</font></td>";
echo"<td BGCOLOR=\"#0096B8\" background=\"/images/blgr016.jpg\">";
echo"<td width=\"30%\"valign=top>$r[author]<br>";
echo"</td></tr>";//end of one news item

05-02-2004, 02:13 PM
It helps if you display the actual code

05-02-2004, 02:36 PM
done. Message is the part im having trouble with.

05-02-2004, 02:47 PM

In your example of a long string of t's being entered, there is no new line character being entered; combine that with the use of percentages for your table column attributes means it will not display on two lines.

There are several ways to solve that problem:

- fix the width of the table cell
- add new line characters to the message at certain points
prior to saving to the database
- add new line characters to the message at certain points
just prior to displaying

I am sure you get the drift


05-02-2004, 03:17 PM
k how do i make it such that once they reach the end of the textbox on each row, that if their in the middle of a word, it will take that word and automatically insert a carriage return and move that word to the next line

05-02-2004, 04:40 PM
nm seems to be working now.