Jump to content

[SOLVED] adding line breaks


contra10

Recommended Posts

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>";
?>

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.