2012-01-26 14 views
-1

데이터베이스의 원본 컨텐츠로 내용을 채우는 편집 페이지가 있는데, 인라인 PHP를 사용하여 필드를 제목으로 채우고 다른 모든 필드도 작동합니다. 시도하고 동일한 방법을 사용하여 텍스트 영역을 채울 때 작동하지 않습니다. 다른 모든 필드는 텍스트 인 textarea를 제외하고 varchar입니다. PHP는 형식 값에 있습니다.데이터베이스에서 textarea로 결과 가져 오기

  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 요소에는 이 없습니다. 사용 :

<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

관련 문제