删除和编辑PHP上简单博客的帖子条目MySQL的

时间:2014-11-23 15:41:13

标签: php mysql edit blogs

根据教程创建了这个脚本但是我想添加一些东西,一个能够编辑和删除帖子。这段代码有效,但老实说我对php知之甚少,怎么能包含这个脚本这样的功能呢?

<body>
<?php
if(isset($_POST['submit'])){
$title = $_POST['title'];
$category = $_POST['category'];
$content = $_POST['content'];

mysql_query("INSERT INTO blogData (title, category, content) VALUE('$title', '$category',  '$content')");
echo "Data has been posted, <a href='index.php'>go index</a>. - <a href='admin.php'>Other Post</a>";
}else{
?>

<div class='container-fluid'>
    <div class='col-md-4 col-md-offset-4'>
  <div class='form-group'>
        <form class='control-label' action='admin.php' method='post'>
        Titulo <input class='form-control' type='text' name='title' /><br />
        Categoria <input class='form-control' type='text' name='category' /><br />
        Contenido <textarea class='form-control' rows='9' name='content'></textarea><br />
    <input class='btn btn-default btn-block' type='submit' name='submit' value='Post' />
    <br><br><br>

    <ul class='breadcrumb'>
      <li><a href='index.php'>index</a></li>
      <li><a href='logout.php'>logout</a></li>
    </ul>
    </form>
  </div>
    <?php
    }
    ?>
    </div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js">      
</script>
</body>

1 个答案:

答案 0 :(得分:-1)

使用PHP Mysql DELETE语句删除帖子,并使用PHP Mysql UPDATE语句编辑现有帖子..它如此简单