RE: keeping format of text in textbox

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:ahemmeri@xxxxxxxxxxx] 
Sent: Friday, 12 November 2004 4:05 PM
To: php-general@xxxxxxxxxxxxx
Subject:  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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux