Use PHP to write your own blog program on Sina app engine. When you create or update an article, use textarea to accommodate the content of the article, and temporarily save the article content to the database as plain text.
The form is like this (in write_article.php):
The SQL statement that saved the article is this (in 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)";
However, when the article is updated (in write_article.php), it is found that there are always six more spaces at the beginning of the text displayed in textarea. Delete the space, and then submit the article. Wait until you edit the article and find that textarea starts with six more spaces.
However, when reading the article , it is found that there are no extra spaces at the beginning of the article.
Think of the solution, so to all of you for help, this extra space is how to go?
Reply content:
Use PHP to write your own blog program on Sina app engine. When you create or update an article, use textarea to accommodate the content of the article, and temporarily save the article content to the database as plain text.
The form is like this (in write_article.php):
The SQL statement that saved the article is this (in 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)";
However, when the article is updated (in write_article.php), it is found that there are always six more spaces at the beginning of the text displayed in textarea. Delete the space, and then submit the article. Wait until you edit the article and find that textarea starts with six more spaces.
However, when reading the article , it is found that there are no extra spaces at the beginning of the article.
Think of the solution, so to all of you for help, this extra space is how to go?
You</code>后面有空格和换行,所以会这样。内容顶着<code><textarea></code>写,</p><p>保存的时候用 <code>$content =trim( $_POST["article_text"] );</code></p><p>就可以了~</p> <p class="answer fmt" data-id="1020000000332993"> <p>改成:</p><pre class="brush:php;toolbar:false"><code><textarea rows="20" cols="80" name="article_text"><?php if($op == "update"){echo $content;} ?>
Note that there are no extra things in textarea, and you have lines and spaces in your original code.