contra10 Posted April 8, 2009 Share Posted April 8, 2009 i have a form set-up where the user inputs writting and its saved in the db, thing is when i take the lines out of the db the query shows all the words in one line with my word string, ie. if a user enters this in the form: ------------------ Dear, John I would like to say hello. Sincerely, Bob ---------------------- it comes out as this in the viewing ---------------------- "Dear, John I would like to say hello. Sincerely, Bob" ---------------------- heres my code to enter <font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 400 characters. )<br> <textarea name="message" wrap="physical" cols="28" rows="4" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 11px; background-color: #72A4D2;" onKeyDown="textCounter(this.form.message,this.form.remLen,400);" // change 125 to anything you wish onKeyUp="textCounter(this.form.message,this.form.remLen,400);"></textarea> don't think thats too necessary but heres the important code when i echo the results <?php $text = ($evdescription); $newtext = wordwrap($text, 80, "<br />\n",true); echo "<table border='0' align='right' width='500'>"; echo"<tr><td>"; echo "<b>COST:</b> $$cost "; if ($username == $creator ){ echo " <a href='http://localhost/events/deleteevent.php?ev=$eidnum'><b>Delete Event </a>| "; echo " <a href='http://localhost/events/updateev.php?ev=$eidnum'> Edit </b></a>"; } echo"</td></tr>"; echo "<tr><td height='25' width='80%' valign='top' align='center' bgcolor='#0183AE'><FONT FACE='ariel' size'12'><h1><b>$evname</b></fOnt></td></tr>"; echo "<tr><td height='175' valign='top' align='center'>$newtext</td></tr>"; echo "<tr><td align='left'><b>Date:</b> $as $evday, $evyear </tr>"; echo "<tr><td aligh='left'><b>Email:</b><i> $evmail</i></td></tr>"; echo "<tr><td align='left'><b>Address:</b>$evaddress</td></tr>"; echo"<tr><td align='left'><b>Time:</b> <font size='2' color='red'>$evhour:$evminute $evtimea - $evhourb:$evminuteb $evtimeb</font></td></tr>"; echo "</table>"; ?> Quote Link to comment Share on other sites More sharing options...
xtopolis Posted April 8, 2009 Share Posted April 8, 2009 nl2br ? Quote Link to comment Share on other sites More sharing options...
nankoweap Posted April 8, 2009 Share Posted April 8, 2009 nl2br would work. another option would be to enclose the text in a <pre></pre> tag. i do this when displaying messages the user typed in and it preserves not only line breaks, but spaces as well as faux html tags the user may have type in like <snip> and such. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.