I use this when submitting the data from the form (for jokes):

if ($submit)
 {
$joke = nl2br($joke);
$dbcnx = @mysql_connect( "localhost", "root", "password");
mysql_select_db("movements"); 
$sql = "INSERT INTO jokes SET author='$author', joke='$joke', id='$id'";
mysql_query($sql);
echo "<b>Thank you, your joke has been recorded!</b>";
}

Then this when displaying the text:


if (!$link = mysql_connect("localhost","root","password"))
exit("Unable to make a connection to the database");
if (!mysql_select_db("movements", $link))
  exit("Unable to select the database");
$table = 'jokes';
$check = "select * from $table ORDER BY rand() LIMIT 100";
$qry = mysql_query($check) or die ("Could not match data because
".mysql_error());
$myrow = mysql_fetch_array($qry);
$joke = str_replace("<br />","\n",$joke);
?>
<table border="1" bgcolor="#0D9BA4">
<tr>
<td width="70%"><b><?echo($myrow['joke']);
?>
</b>
</td>
<td valign="top"><b>Kindly provided by
<?echo($myrow['author']);?> </b>
</td>
</tr>
<table>

Excuse the crap code, I'm pretty new to php :)

-----Original Message-----
From: Amanda Hemmerich [mailto:[EMAIL PROTECTED] 
Sent: Friday, 12 November 2004 4:05 PM
To: [EMAIL PROTECTED]
Subject: [PHP] keeping format of text in textbox


I did a search for this in the archive but didn't find anything.

Is there a way to preserve the format of text in a textbox that is being
saved in a database and then pulled out and displayed?  The people
entering the data want to keep their tabs and newlines, but right now,
that's not happening.  

Thanks,
Amanda

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to