当前位置:Gxlcms > PHP教程 > 为什么在textarea中显示编辑内容时,开头总有6个多的空格

为什么在textarea中显示编辑内容时,开头总有6个多的空格

时间:2021-07-01 10:21:17 帮助过:23人阅读

在sina app engine上用php写自己的博客程序。 在创建或更新文章时,用 textarea 来容放文章内容, 暂时以纯文本的形式将文章内容保存到数据库。

表单是这样的(在write_article.php中):


保存文章的sql语句是这样的(在save_article.php中)。

$content = $_POST["article_text"];
// update article
$sql = "update article set title=\"$title\",type=\"$category\",content=\"$content\",summary=\"$summary\",updatetime=\"$datetime\" where id=$id";
... ...
// save new article
$sql = "insert into article values ($id, \"$category\", \"$title\", \"$author\", \"$summary\", \"$content\", \"$datetime\", \"$datetime\", $hits)";

但是更新文章时(在write_article.php中进行), 发现在textarea中显示的文本开头总是多出六个空格。 删除掉空格,再提交文章。 等到再编辑文章时,发现textarea开头还是多出六个空格。

但在 阅读文章 时,发现文章开头并没有多出的空格。

百思不得其解,所以向各位求助,这多出的空格是怎么回事呢?

回复内容:

在sina app engine上用php写自己的博客程序。 在创建或更新文章时,用 textarea 来容放文章内容, 暂时以纯文本的形式将文章内容保存到数据库。

表单是这样的(在write_article.php中):


保存文章的sql语句是这样的(在save_article.php中)。

$content = $_POST["article_text"];
// update article
$sql = "update article set title=\"$title\",type=\"$category\",content=\"$content\",summary=\"$summary\",updatetime=\"$datetime\" where id=$id";
... ...
// save new article
$sql = "insert into article values ($id, \"$category\", \"$title\", \"$author\", \"$summary\", \"$content\", \"$datetime\", \"$datetime\", $hits)";

但是更新文章时(在write_article.php中进行), 发现在textarea中显示的文本开头总是多出六个空格。 删除掉空格,再提交文章。 等到再编辑文章时,发现textarea开头还是多出六个空格。

但在 阅读文章 时,发现文章开头并没有多出的空格。

百思不得其解,所以向各位求助,这多出的空格是怎么回事呢?

注意 textarea 中不要有任何多余的东西,你原来的代码里有换行和空格。

人气教程排行