thinkphp 点击分类显示分类下的文章(完整)
控制器
<?php // 本类由系统自动生成,仅供测试用途 class IndexAction extends Action { public function index(){ $cate=M('wzfl'); $list=$cate->field("id,name,pid,path,concat(path,'-',id) as bpath")->order('bpath')->select(); foreach($list as $key=>$value){ $list[$key]['count']=count(explode('-',$value['bpath'])); } $this->assign('div',$list); $this->display(); } public function flcx(){ header("Content-type:text/html;charset=utf-8");//容易出错的地方 $id = $_GET['id'];//接收id $Dao = M(); $sql = "SELECT xp_wztj.bt,xp_wztj.time,xp_wztj.gjz,xp_wztj.wz,xp_wzfl.name FROM xp_wztj, xp_wzfl WHERE xp_wztj.uid = xp_wzfl.id and xp_wzfl.id=$id order by xp_wztj.id desc"; $list = $Dao->query($sql); //echo "成功!"; dump($list); } }
显示器
<head> <style type="text/css"> .button{ display: inline-block; *display: inline; zoom: 1; padding: 6px 20px; margin: 0; cursor: pointer; border: 1px solid #bbb; overflow: visible; font: bold 13px arial, helvetica, sans-serif; text-decoration: none; white-space: nowrap; color: #555; background-color: #ddd; background-image: linear-gradient(top, rgba(255,255,255,1), rgba(255,255,255,0)), url(data:image/png;base64,iVBORw0KGg[...]QmCC); transition: background-color .2s ease-out; background-clip: padding-box; /* Fix bleeding */ border-radius: 3px; box-shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 2px 2px -1px rgba(0, 0, 0, .5), 0 1px 0 rgba(255, 255, 255, .3) inset; text-shadow: 0 1px 0 rgba(255,255,255, .9); } .button:hover{ background-color: #eee; color: #555; } .button:active{ background: #e9e9e9; position: relative; top: 1px; text-shadow: none; box-shadow: 0 1px 1px rgba(0, 0, 0, .3) inset; } .kj { text-align:center; border:2px solid #a1a1a1; padding:10px 40px; background:#dddddd; width:550px; border-radius:25px; -moz-border-radius:25px; /* 老的 Firefox */ } .list-tt{ text-align:center; border:2px solid #a1a1a1; padding:10px 40px; background:#fff;; width:400px; border-radius:25px; -moz-border-radius:25px; /* 老的 Firefox */ } .shadow { -webkit-box-shadow: 0px 0px 5px #ff4848; -moz-box-shadow: 0px 0px 5px #ff4848; box-shadow: 0px 0px 5px #ff4848; } input:focus { -webkit-box-shadow: 0px 0px 5px #007eff; -moz-box-shadow: 0px 0px 5px #007eff; box-shadow: 0px 0px 5px #007eff; } a, a:visited { color: #000; text-decoration: none; text-shadow: 0px 1px 0px #fff; } a:hover { border-bottom: 1px dotted #fff; } </style> </head> <body> <form method="post"> <div class="kj"> <div class="list-tt" >文章分类: </div> <foreach name="div" item="vo"> <div class="list-tt" > id:{$vo.id} | 分类:{$vo.name} | <a href="{:U('flcx',array('id'=>$vo['name']))}">查看文章</a> </div> </foreach> </div> </form> </body>
效果图
这样下来,整个的无限极分类构架或者思想才算是完成