【毕业设计】【期末作业】新闻发布系统(php+mysql)

news/2024/7/24 9:36:27 标签: php, thinkphp, mysql, html, javascript
htmledit_views">

分享一个新闻发布系统网站,后台主要是采用html" title=php>php的thinkhtml" title=php>php框架制做的,数据库采用html" title=mysql>mysql进行处理

这个系统主要分为用户模块和后台管理模块,具体功能有

用户模块:注册,登陆,查看个人信息,修改个人信息,站内搜索,新闻浏览等功能   

后台管理员模块:会员管理,新闻公告,分类管理,新闻管理,评论管理,留言管理等。

这个项目可以在电脑本地正常运行,可以做为毕业设计或者计算机作业

相关页面的界面如下:

1、新闻网站首页
1、新闻网站首页
2、新闻网站首页
2、新闻网站首页
3、新闻网站首页
3、新闻网站首页
4、新闻分类相关文章
4、新闻分类相关文章
5、新闻详情页
5、新闻详情页
6、新闻详情页分类
6、新闻详情页--评论
7、新闻发布后台管理
7、新闻发布后台管理
8、新闻发布后台管理
8、新闻发布后台管理

新闻首页html 

{include file="public/header"}
    <!-- header slider -->
    <div class="slate_gray">
        <div class="container">
            <div class="row header_news_panel">
                <!-- Tab panes -->
                <div class="col-sm-8 tab-content  tab-content_mob-p0" id="img">
                    {foreach name="fourNews" id="vo"}
                    <div role="tabpanel" class="tab-pane fade" id="news{$vo.id}">
                        <img src="{$vo.image}" alt="main img" class="tab-pane__img">
                        <div class="header_news_text tab-pane__block">
                            <p class="tab-pane__category yel_line">{$vo.cat}</p>
                            <a href="{:url('news/detail',['id'=>$vo.id])}" class="tab-pane__title">{$vo.title}</a>
                        </div>
                    </div>
                    {/foreach}
                </div>
                <!-- END Tab panes -->
                <!-- Nav tabs -->
                <div class="col-sm-4 news-tabs">
                    <p class="news-tabs__title h2">最新</p>
                    <ul class="news-tabs__nav nav nav-tabs shadow_text" role="tablist">
                        {foreach name="fourNews" id="vo"}
                        {if condition="$key < 5"}
                        <li role="presentation" ><!--  class="active" -->
                            <a href="#news{$vo.id}" role="tab" data-toggle="tab">
                                <span class="time">{$vo.create_time}</span>
                                {$vo.title}
                            </a>
                        </li>
                        {/if}
                        {/foreach}
                    </ul>
                </div>
                <!-- END Nav tabs -->
            </div>
        </div>
    </div>
    <!-- END header slider -->
    <!-- top news-->
    <section>
        <!-- top news -->
        <!-- title -->
        <div class="wrap wrap_white">
            <div class="container title">
                <h1 class="title__h1 underscore">公告栏</h1>
            </div>
        </div>
        <!-- END title -->
        <div class="wrap wrap_gray pt20">
            <div class="container">
                <div class="row" >
                    {foreach name="notices" id="vo"}
                    <div class="twitter__header" style="">
                        <p class="twitter__header__name"><a href="{:url('notice/index',['id'=>$vo.id])}">{$vo.title}</a></p>
                    </div>
                    {/foreach}
                </div>
            </div>
        </div>
        <!-- /container-->
    </section>
    <!-- 按访问量高低显示前9条新闻 -->
    <section>
            <!-- top news -->
            <!-- title -->
            <div class="wrap wrap_white">
                <div class="container title">
                    <h1 class="title__h1 underscore">最热新闻</h1>
                </div>
            </div>
            <!-- END title -->
            <div class="wrap wrap_gray pt20">
                <div class="container">
                    <div class="row">
                        {foreach name="hotNews" id="vo"}
                        {if condition="$key eq 0"}
                        <div class="col-sm-6">
                            <div class="thumbnail thumbnail_big">
                                <img src="{$vo.image}" height="350" width="560" alt="News">
                                <div class="caption thumbnail__caption">
                                    <div class="news caption__news">
                                        <p class="news__category yellow-line">{:getCategoryNameById($vo.category_id)}</p>
                                        <a href="{:url('news/detail',['id'=>$vo.news_id])}" class="news__head">{$vo.title}</a>
                                        <p class="news__desc">{$vo.content|html_entity_decode|strip_tags|mb_substr=0,260,'utf-8'}......</p>
                                    </div>
                                    <div class="posted">
                                        <span class="posted__date">{$vo.create_time}</span>
                                        <ul class="posted__icon">
                                            <li>
                                                <span>
                                                <i class="icon-comment-empty"></i>{:getCommentsByNewsId($vo.news_id)}
                                            </span>
                                            </li>
                                            <li>
                                                <span>
                                                <i class="icon-eye"></i>{$vo.counter}
                                            </span>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {/if}
                        {/foreach}
                        {foreach name="hotNews" id="vo"}
                        {if condition="($key > 0) AND ($key < 9)"}
                        <div class="col-sm-3">
                            <div class="thumbnail thumbnail_small">
                                <a href="{:url('news/detail',['id'=>$vo.news_id])}" class="thumbnail__link">
                                    <img src="{$vo.image}" height="153" width="270" alt="News">
                                </a>
                                <div class="caption thumbnail__caption">
                                    <div class="news caption__news">
                                        <p class="news__category yellow-line">{:getCategoryNameById($vo.category_id)}</p>
                                        <a href="{:url('news/detail',['id'=>$vo.news_id])}" class="news__link">
                                            <p class="news__text">{$vo.title}</p>
                                        </a>
                                    </div>
                                    <div class="posted">
                                        <span class="posted__date">{$vo.create_time}</span>
                                        <ul class="posted__icon">
                                            <li>
                                                <span>
                                                <i class="icon-comment-empty"></i>{:getCommentsByNewsId($vo.news_id)}
                                            </span>
                                            </li>
                                            <li>
                                                <span>
                                                <i class="icon-eye"></i>{$vo.counter}
                                            </span>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {/if}
                        {/foreach}
                        </div>
                    </div>
                </div>
            </div>
            <!-- /container-->
        </section>
    <!-- /按访问量高低显示前9条新闻 -->
    {foreach name="parentCategorys" id="vo"}
    <section>
        <!-- top news -->
        <!-- title -->
        <div class="wrap wrap_white">
            <div class="container title">
                <h1 class="title__h1 underscore">{:getCategoryNameById($vo.id)}</h1>
            </div>
        </div>
        <!-- END title -->
        <div class="wrap wrap_gray pt20">
            <div class="container">
                <div class="row">
                    {if condition="$vo.haveOneNews eq 1"}
                    <div class="col-sm-6">
                        <div class="thumbnail thumbnail_big">
                            <img src="{$vo.oneNews.0.image}" height="350" width="560" alt="News">
                            <div class="caption thumbnail__caption">
                                <div class="news caption__news">
                                    <p class="news__category yellow-line">{:getCategoryNameById($vo.oneNews.0.category_id)}</p>
                                    <a href="{:url('news/detail',['id'=>$vo.oneNews.0.id])}" class="news__head">{$vo.oneNews.0.title}</a>
                                    <p class="news__desc">{$vo.oneNews.0.content|html_entity_decode|strip_tags|mb_substr=0,260,'utf-8'}......</p>
                                </div>
                                <div class="posted">
                                    <span class="posted__date">{$vo.oneNews.0.create_time}</span>
                                    <ul class="posted__icon">
                                        <li>
                                            <span>
                                            <i class="icon-comment-empty"></i>{:getCommentsByNewsId($vo.oneNews.0.id)}
                                        </span>
                                        </li>
                                        <li>
                                            <span>
                                            <i class="icon-eye"></i>{:getCounterByNewsId($vo.oneNews.0.id)}
                                        </span>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    {/if}
                    {if condition="$vo.haveNineNews eq 1"}
                    {foreach name="$vo.nineNews" id="v"}
                    {if condition="($key>0) AND ($key < 5 )"}
                    <div class="col-sm-3">
                        <div class="thumbnail thumbnail_small">
                            <a href="{:url('news/detail',['id'=>$v.id])}" class="thumbnail__link">
                                <img src="{$v.image}" height="153" width="270" alt="News">
                            </a>
                            <div class="caption thumbnail__caption">
                                <div class="news caption__news">
                                    <p class="news__category yellow-line">{:getCategoryNameById($v.category_id)}</p>
                                    <a href="{:url('news/detail',['id'=>$v.id])}" class="news__link">
                                        <p class="news__text">{$v.title}</p>
                                    </a>
                                </div>
                                <div class="posted">
                                    <span class="posted__date">{$v.create_time}</span>
                                    <ul class="posted__icon">
                                        <li>
                                            <span>
                                            <i class="icon-comment-empty"></i>{:getCommentsByNewsId($v.id)}
                                        </span>
                                        </li>
                                        <li>
                                            <span>
                                            <i class="icon-eye"></i>{:getCounterByNewsId($v.id)}
                                        </span>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    {/if}
                    {/foreach}
                    {/if}
                </div>
                <div class="row">
                    {if condition="$vo.haveNineNews eq 1"}
                    {foreach name="$vo.nineNews" id="v"}
                    {if condition="($key>4) AND ($key < 9 )"}
                    <div class="col-sm-3">
                        <div class="thumbnail thumbnail_small">
                            <a href="{:url('news/detail',['id'=>$v.id])}" class="thumbnail__link">
                                <img src="{$v.image}" height="153" width="270" alt="News">
                            </a>
                            <div class="caption thumbnail__caption">
                                <div class="news caption__news">
                                    <p class="news__category yellow-line">{:getCategoryNameById($v.category_id)}</p>
                                    <a href="{:url('news/detail',['id'=>$v.id])}" class="news__link">
                                        <p class="news__text">{$v.title}</p>
                                    </a>
                                </div>
                                <div class="posted">
                                    <span class="posted__date">{$v.create_time}</span>
                                    <ul class="posted__icon">
                                        <li>
                                            <span>
                                            <i class="icon-comment-empty"></i>{:getCommentsByNewsId($v.id)}
                                        </span>
                                        </li>
                                        <li>
                                            <span>
                                            <i class="icon-eye"></i>{:getCounterByNewsId($v.id)}
                                        </span>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    {/if}
                    {/foreach}
                    {/if}
                </div>
            </div>
            <!-- btn load-->
            {if condition="$vo.haveNineNews eq 1"}
            <div class="ajax_load">
                <a style="color: #000" target="_blank" href="{:url('news/category',['id'=>$vo.id])}">更多文章</a>
            </div>
            {/if}
            <!-- END btn load-->
        </div>
        <!-- /container-->
    </section>
    {/foreach}
    <!-- /top news -->
{include file="public/footer"}
<script type="text/javascript">
    $(document).ready(function(){
        /*最新文章第一个默认是选中*/
        ele = $('.news-tabs__nav li:first-child').addClass('active');
        ssele = $('#img div:first-child').addClass(' in active');
    });
</script>

新闻首页controller

<?html" title=php>php 

namespace app\index\controller;
use \think\Controller;
use app\index\controller\Base;
class Index extends Base{
	/*首页*/
	public function index(){
		$notices = Model('Notice')->getNoticeTen();
		/*首页的四个最新新闻*/
		$fourNews = Model('News')->getNewsFour();
		foreach ($fourNews as $key => $value) {
			$value['cat'] = Model('Category')->get($value['category_id'])['name'];
		}
		//获取所有的父类ID
		$parentCategorys = Model('Category')->getParentCategory();
		foreach ($parentCategorys as $key => $value) {
			//获取每一个分类的前一个
			$value['oneNews'] = Model('News')->getOneNewsByCategoryId($value['id']) ;
			$value['oneNews'] = $value['oneNews'] ;
			if(empty($value['oneNews'])){
				$value['haveOneNews'] = 0;
			}else{
				$value['haveOneNews'] = 1;
			}
			/*获取每个分类的前九个新闻*/
			$value['nineNews'] = Model('News')->getNineNewsByCategoryId($value['id']);
			if(empty($value['nineNews'])){
				$value['haveNineNews'] = 0;
			}else{
				$value['haveNineNews'] = 1;
			}
		}
		/*最热新闻*/
		$hotNews = Model('News')->hotNews();
		foreach ($hotNews as $key => $value) {
			// $hotNews[$key]['image'] = json_decode($value['image']);
			$hotNews[$key]['cat'] = Model('Category')->get($value['category_id'])['name'];
		}
		// p($hotNews);exit();
		return $this->fetch('',[
			'categorys'=>$this->categorys,
			'user'=>$this->user,
			'notices'=>$notices,
			'fourNews'=>$fourNews,
			'parentCategorys'=>$parentCategorys,
			'hotNews'=>$hotNews,
		]);
		// return json([
		// 	'code'=>1,
		// 	'msg'=>'获取成功',
		// 	'categorys'=>$this->categorys,
		// 	'user'=>$this->user,
		// 	'notices'=>$notices,
		// 	'fourNews'=>$fourNews,
		// 	'parentCategorys'=>$parentCategorys,
		// 	'hotNews'=>$hotNews,
		// ]);
	}
	/*访问量*/
	public function counter(){
		$data = input('post.');
		$data['counter'] = Model('Counter')->getCounterByNewsId($data['news_id']);
		p($data );
		if($data['counter'] == ''){
			$data['counter'] = 1;
			Model('Counter')->save($data);
		}else{
			$data['counter'] += 1;
			$data['update_time'] = date('Y-m-d H:i:s',time());
			model('Counter')->update($data,['news_id'=>intval($data['news_id'])]);
		}
	}
}


 ?>

以上是我项目的相关界面和代码,如果你有什么技术上的难题,开发时遇到的问题,欢迎随时交流

 

微信小程序二手闲置商城校园跳蚤物品交换 免费信息发布系统功能源码(微信小程序和html" title=php>php后台管理)


http://www.niftyadmin.cn/n/1385496.html

相关文章

在spring的bean中获取ServletContext

我的需求是获取spring开发的web项目在服务器上的绝对路径。进而引申到我需要知道servletContext&#xff0c;因为servletContext有一个servletContext.getRealPath("/");方法&#xff0c;这个方法就能获取项目的绝对路径。常规方式下我们如何获取servletContext呢&am…

关于 logger

日志 前言 我是一名后台程序员&#xff0c;接触后台只有一年时间&#xff0c;在这期间一共做过四个项目&#xff0c;分别是&#xff1a; 工作室招新系统视频学习网站创客网站打印机项目由于之前做项目的时候没有好好重视日志&#xff0c;所以导致在开发与维护项目出现了很多问题…

重构——51移除设值函数(Remove Setting Method)

移除设值函数&#xff08;Remove Setting Method&#xff09; 类中的某个字段应该在对象创建时被设值&#xff0c;然后就不再改变&#xff1b;去掉该字段的所有设值函数 一、动机 不希望对象被改变&#xff0c;就不要提供设值函数&#xff0c;同时final之 二、做法 1、检查设值…

Virtualbox 复制vdi文件

2019独角兽企业重金招聘Python工程师标准>>> VirtualBox可不像VMware那样&#xff0c;直接复制虚拟磁盘文件就可以了事的&#xff0c;只因为VirtualBox识别虚拟磁盘文件VDI采用了uuid识别技术. 由于测试需要搭建局域网环境&#xff0c;需要两台虚拟机同时运行。当我…

springmvc初始化数据

在使用springmvc时,我们也会在项目启动时初始化一些数据&#xff0c;具体的方式见下面的链接。这里我只贴一下InitializingBean的例子。注意事项:springmvc和sping整合时,配置注解的注意事项&#xff01;不注意会导致我们的controller实例或其他的实例在初始化时加载两次&#…

The type R is already defined 错误解决办法

今天在导入一个开源项目的时候遇到了The type R is already defined的错误&#xff0c;试过了删除R&#xff0c;clear project都还是报这个错&#xff0c;Google一下之后找到了解决办法在 Project->Properties->Builders&#xff0c;把Java-Builder的选择去掉&#xff0c…

apache下安装PHP

rpm -qa zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel 或者rpm -qa zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel如果没有可以使用yum来安装yum…

Java String.split()注意点

//String[] aa "aaa|bbb|ccc".split("|");//错误String[] aa "aaa|bbb|ccc".split("\\|"); //正确for (int i 0 ; i <aa.length ; i ) {System.out.println("--"aa[i]); } “.”和“|”都是转义字符,必须得加"\\…