Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fac9e90

Browse files
案例blog,增加删除文章功能
1 parent ebeaad8 commit fac9e90

File tree

4 files changed

+94
-72
lines changed

4 files changed

+94
-72
lines changed

‎.idea/workspace.xml‎

Lines changed: 69 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年11月9日
6+
* Time: 23:27
7+
*/
8+
require '../class/conn.php';
9+
$url = $_SERVER["QUERY_STRING"];
10+
$url_parse = explode('=', $url);
11+
$id = $url_parse[1];
12+
echo $id;
13+
14+
$sys_conn = new ConnDB();
15+
$conn = $sys_conn->GetConn();
16+
mysqli_query($conn,"set names 'utf8' ");
17+
18+
$sql = mysqli_query($conn,"delete from tb_blog where id='$id'");
19+
if($sql){
20+
$sys_conn->CloseConn();
21+
echo "<script>alert('删除成功!');window.location.href= '/php-mysql/blog/dashboard.php';</script>";
22+
}else{
23+
echo "<script>alert('操作失败!')</script>";
24+
}

‎php-mysql/blog/controller/update_blog.php‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
$sys_conn = new ConnDB();
1515
$conn = $sys_conn->GetConn();
1616
mysqli_query($conn,"set names 'utf8' ");
17-
//$blog_id= $_POST['id'];
1817
$blog_title = $_POST['blog_title'];
1918
$blog_tag = $_POST['blog_tag'];
2019
$blog_content = $_POST['blog_content'];
21-
echo $blog_content.'<br>';
2220

23-
echo 'id:'.$id;
2421
$sql1 = mysqli_query($conn,"update tb_blog set title='$blog_title',tag='$blog_tag',content='$blog_content' where id='$id'");
2522
if($sql1){
2623
$sys_conn->CloseConn();

‎php-mysql/blog/dashboard.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
echo "<li class='blog-item'><div class='item-title'><h4><a href='/php-mysql/blog/article.php?id=$id' target='_blank'>".$item[$i]['title']."</a></h4></div>"
8383
."<div class='item-tag'><a href='#' class='btn btn-info'>".$item[$i]['tag']."</a></div >"
8484
."<div class='item-content'>".$item_content."</div >"
85-
."<div ><a href='/php-mysql/blog/edit.php?id=$id' class='btn btn-info' target='_blank'>编辑</a><a href='/php-mysql/blog/delete.php?id=$id' class='btn btn-warning' target='_blank'>删除</a></div>"
85+
."<div class='item-manage'><a href='/php-mysql/blog/edit.php?id=$id' class='btn btn-info' target='_blank'>编辑</a><a href='/php-mysql/blog/controller/delete_blog.php?id=$id' class='btn btn-warning' target='_blank'>删除</a></div>"
8686
."</li >" ;
8787
}
8888
?>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /