Skip to content

Commit ebeaad8

Browse files
案例blog,编辑文章功能完善
1 parent 6c79c32 commit ebeaad8

File tree

3 files changed

+61
-66
lines changed

3 files changed

+61
-66
lines changed

.idea/workspace.xml

Lines changed: 52 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

php-mysql/blog/controller/update_blog.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@
77
*/
88
//编辑文章
99
require '../class/conn.php';
10+
$url = $_SERVER["QUERY_STRING"];
11+
$url_parse = explode('=', $url);
12+
$id = $url_parse[1];
1013

1114
$sys_conn = new ConnDB();
1215
$conn = $sys_conn->GetConn();
1316
mysqli_query($conn,"set names 'utf8' ");
14-
$blog_id= $_POST['id'];
17+
//$blog_id= $_POST['id'];
1518
$blog_title = $_POST['blog_title'];
1619
$blog_tag = $_POST['blog_tag'];
1720
$blog_content = $_POST['blog_content'];
1821
echo $blog_content.'<br>';
1922

20-
echo 'id:'.$blog_id;
21-
$sql1 = mysqli_query($conn,"update tb_blog set title='$blog_title',tag='$blog_tag',content='$blog_content' where id='$blog_id'");
23+
echo 'id:'.$id;
24+
$sql1 = mysqli_query($conn,"update tb_blog set title='$blog_title',tag='$blog_tag',content='$blog_content' where id='$id'");
2225
if($sql1){
2326
$sys_conn->CloseConn();
24-
echo "<script>alert('更新文章内容成功!');//window.location.href= '/php-mysql/blog/dashboard.php';</script>";
27+
echo "<script>alert('更新文章内容成功!');window.location.href= '/php-mysql/blog/dashboard.php';</script>";
2528
}else{
2629
echo "<script>alert('保存信息失败!')</script>";
2730
}

php-mysql/blog/edit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ function get_blog_list($id){
4545
<div class="content col-md-10 col-md-offset-1">
4646
<div class="add-blog col-sm-12">
4747
<div class="breadcrumb"><a href="index.php" style="margin-right:5px ">文章</a>\<span style="margin-left: 5px"><?php echo $id ?></span></div>
48-
<form class="form-group form-horizontal" action="controller/update_blog.php" method="post" name="edit-blog-form">
48+
<form class="form-group form-horizontal" action="controller/update_blog.php?id=<?php echo $id ?>" method="post" name="edit-blog-form">
4949
<div class="blog_id form-group col-sm-12 clearfix">
5050
<label for="blog_id" class="col-sm-1 control-label" style="text-align: left">id:</label>
5151
<div class="col-sm-11">
52-
<input type="text" class="form-control" name="id" id="blog_id" placeholder="<?php echo $item['id'] ?>" />
52+
<input type="text" class="form-control" name="blog_id" id="blog_id" placeholder="<?php echo $item['id'] ?>" />
5353
</div>
5454
</div>
5555
<div class="blog_title form-group col-sm-12 clearfix">

0 commit comments

Comments
 (0)