文章编辑不工作的PHP

时间:2017-12-11 11:28:41

标签: php html

我对文章编辑很有疑问。我需要选择文章并将其放置到表格(标题和文本区域)。但我甚至无法打开它。你可以帮我吗?感谢。

<?php

session_start();

include_once('../includes/conn.php');
include_once('../includes/article.php');

$article= new Article;

if(isset($_SESSION['logged_in'])){
$articles=$article->fetch_all();

 if(isset($_POST['id'])){
  $id=$_POST['id'];

$query=$pdo->prepare('SELECT * FROM articles WHERE article_id=?');
$query->bindValue(1,$id);
$query->execute();
}
?>
<html>
<form action="" method="post" autocomplete="off">
  <input type="text" name="title" value="<?php echo 
  $article['article_title'];?>"/><br/><br/>
  <textarea rows="15" cols="50" value="<?php echo 
  $article['article_content'];?>" name="content"></textarea><br/><br/>
  <input type="submit" value="Add article"/>
 </html>
<?php
} else {
 header('Location: index.php');
}
?>

1 个答案:

答案 0 :(得分:-1)

textarea没有值属性,您必须将值放在textarea的开始和结束标记之间

<?php

session_start();

include_once('../includes/conn.php');
include_once('../includes/article.php');

$article= new Article;

if(isset($_SESSION['logged_in'])){
    $articles=$article->fetch_all();

    if(isset($_POST['id'])){
        $id=$_POST['id'];

        $query=$pdo->prepare('SELECT * FROM articles WHERE article_id=?');
        $query->bindValue(1,$id);
        $query->execute();
    }
?>
<html>
<form action="" method="post" autocomplete="off">
  <input type="text" name="title" value="<?php echo 
  $article['article_title'];?>"/><br/><br/>
  <textarea rows="15" cols="50" name="content"><?php echo 
  $article['article_content'];?></textarea><br/><br/>
  <input type="submit" value="Add article"/>
 </html>
<?php
} else {
 header('Location: index.php');
}
?>