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 cec21eb

Browse files
案例blog,文章详情页功能实现
1 parent d52917c commit cec21eb

File tree

6 files changed

+182
-116
lines changed

6 files changed

+182
-116
lines changed

‎.idea/workspace.xml‎

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

‎php-mysql/blog/article.php‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zq199
5+
* Date: 2016年11月8日
6+
* Time: 23:29
7+
*/
8+
require 'class/system.php';
9+
10+
$url = $_SERVER["QUERY_STRING"];
11+
$url_parse = explode('=', $url);
12+
$id = $url_parse[1];
13+
function get_blog_list($id){
14+
$sys_conn1 = new ConnDB();
15+
$conn = $sys_conn1->GetConn();
16+
mysqli_query($conn,"set names 'utf8' ");
17+
18+
$sql = mysqli_query($conn," select *from tb_blog where id='$id'");
19+
$info = mysqli_fetch_array($sql);
20+
21+
return $info;
22+
}
23+
$item = get_blog_list($id);
24+
?>
25+
<!DOCTYPE html>
26+
<html lang="en">
27+
<head>
28+
<meta charset="UTF-8">
29+
<title><?php echo SITE_NAME ?>| 编辑文章</title>
30+
<link rel="stylesheet" href="css/bootstrap.min.css">
31+
<link rel="stylesheet" href="css/style.css">
32+
<style>
33+
.control-label{
34+
line-height: 34px;
35+
margin-bottom: 0;
36+
}
37+
</style>
38+
</head>
39+
<body>
40+
<?php include 'header.php'; ?>
41+
<div class="content col-md-10 col-md-offset-1">
42+
<div class="add-blog col-sm-12">
43+
<div class="breadcrumb"><a href="index.php" style="margin-right:5px ">文章</a>\<span style="margin-left: 5px"><?php echo $id ?></span></div>
44+
<div class="article-title col-sm-12 text-center"><h4><?php echo $item['title'] ?></h4></div>
45+
<div class="article-tag">标签:<a href='#' class='btn btn-info' style=" padding: 2px 8px;"><?php echo $item['tag'] ?></a></div>
46+
<div class="article-content col-sm-12" style="margin-top: 10px"><?php echo $item['content'] ?></div>
47+
</div>
48+
</div>
49+
<?php include 'footer.php'; ?>
50+
</body>
51+
</html>
52+
53+
54+

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function get_blog_list($username){
4242
$this->blog_list = $blog_list;
4343
}
4444
function show_blog_list(){
45-
return $this->blog_list;
46-
}
45+
return $this->blog_list;
46+
}
4747
}
4848
$home_data = new getData();
4949
$home_data->get_data($_COOKIE['user_name']);

‎php-mysql/blog/dashboard.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
$item_content = mb_substr($item[$i]['content'],0,160). '...';
7474
} else{ $item_content = $item[$i]['content'];}
7575

76-
echo "<li ><div class='item-title'>".$item[$i]['title']."<h4></h4></div>"
76+
echo "<li class='blog-item'><div class='item-title'><h4>".$item[$i]['title']."</h4></div>"
7777
."<div class='item-tag'><a href='#' class='btn btn-info'>".$item[$i]['tag']."</a></div >"
7878
."<div class='item-content'>".$item_content."</div ></li >" ;
7979
}

‎php-mysql/blog/edit.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
//内容编辑页面
99
require 'class/system.php';
10-
require '';
10+
require '';
1111
//主页
1212
?>
1313
<!DOCTYPE html>

‎php-mysql/blog/index.php‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,15 @@
3535
$item = $home_data->show_blog_list();
3636
$num = count($item);
3737
for($i=0;$i<$num;$i++){
38-
echo "<li class='blog-item'><div class='item-title'>".$item[$i]['title']."<h4></h4></div>"
38+
$id = $i+1;
39+
$item_content = '';
40+
if(strlen($item[$i]['content'])>160){
41+
$item_content = mb_substr($item[$i]['content'],0,160). '...';
42+
} else{ $item_content = $item[$i]['content'];}
43+
44+
echo "<li class='blog-item'><div class='item-title'><h4><a href='/php-mysql/blog/article.php?id=$id'>".$item[$i]['title']."</a></h4></div>"
3945
."<div class='item-tag'><a href='#' class='btn btn-info'>".$item[$i]['tag']."</a></div >"
40-
."<div >".$item[$i]['content']."</div ></li >" ;
46+
."<div class='item-content'>".$item_content."</div ></li >" ;
4147
}
4248
?>
4349
</ul>

0 commit comments

Comments
(0)

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