2012-01-26 10 views
-1

私はデータベースの元のコンテンツをコンテンツに埋め込む編集ページを持っています。私はインラインphpを使用しています。これによりタイトルがフィールドに取り込まれ、他のフィールドもすべて機能します。同じメソッドを使用してテキストエリアを入力しようとすると、動作しません。 他のすべてのフィールドは、textarea(テキスト)以外はvarcharです。 phpはフォームの値にあります。データベースからの結果をテキストエリアに取得

  require_once('includes/db.inc.php'); 
      $stmt = $mysqli->prepare("SELECT 
          postID,title,content,author,image 
          FROM posts where postID = ?"); 
      $stmt->bind_param("i",$_GET['postID']); 
      $stmt->execute(); 
      $stmt->bind_result($postID,$title,$content,$author,$image); 
      $stmt->fetch(); 
      $stmt->close(); 


      ?> 
      <section id="createPost"> 
       <form method="post" action="editPost.php"> 
        <fieldset> 
         <legend>Edit Post: <?php echo $title ?></legend> 
         <input name="postID" type="hidden" value="<?php echo $postID; ?>"> 
         <label for="titleOfPost">Title of Post:</label><br /> 
         <input type="text" name="titleOfPost" size="82" placeholder="Enter title of post" required value="<?php echo $title ?>"><br /> 
         <label for="bodyOfPost">Content of Post:</label><br /> 
         <textarea cols="60" name="postContent" rows="10" placeholder="HTML tags allowed" value="<?php echo $content ?>"></textarea><br /> 
         <label for="authorOfPost">Author:</label><br /> 
         <input type="text" name="authorOfPost" size="82" placeholder="Author name" required value="<?php echo $author ?>"><br /> 
         <label for="imageOfPost">Image:</label><br /> 
         <input type="text" name="imageOfPost" size="82" placeholder="image" value="<?php echo $image ?>"><br /> 


         <input type="submit" name="newPostBtn" value="EditPost" id="newPostBtn"/> 
        </fieldset> 
       </form> 
      </section><!--end createPost--> 
+0

何かがうまくいかないときは、常に、常に、常に、常に、生成されたHTMLソースコードを見ることから始めます。もしあなたがこれを済ませれば、データが実際にブラウザに送られているのを見て、これはPHP/MySQLiの問題ではなく、 'textarea'タグの誤解による単純なHTMLの問題であることが分かりました。 – kba

答えて

5

テキストエリア要素には、プロパティがありません。です。使用:

<textarea cols="60" name="postContent" rows="10" placeholder="HTML tags allowed"><?php echo $content ?></textarea> 
+0

クラッシュスピードが最初に来た:) –

5

テキストエリアには、他の入力タイプと同じように入力されません。内容は、開始タグ内ではないタグ(アンカータグなど)(イメージタグなど)の間を移動します。

+0

私はまだテキストエリアの値にPHPが必要ですか?または重要ではありません。 – StudentRik

+0

テキストエリアの値プロパティはありません。あなたは ' ' – Crashspeeder

+2

@StudentRik [ドキュメントを読む](http://www.w3.org/TR/html4/interact/forms.html#h-17.7)。 'textarea'は' value'属性を持ちません。 – kba

関連する問題