RE: [PHP] keeping format of text in textbox
| From: | Justin dot Baiocchi at csiro dot au | Date: | Fri, 12 Nov 2004 05:11:06 +0000 |
| Subject: | RE: [PHP] keeping format of text in textbox | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-201815@lists.php.net to get a copy of this message | ||
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@indiana.edu]
Sent: Friday, 12 November 2004 4:05 PM
To: php-general@lists.php.net
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