149条记录

doyophp 通过获取对应年份的文章数量

php

$w=" FROM_UNIXTIME(addtime, '%Y') = ".$this->syArgs('year')." ";
		$f=syDB('article')->findSql('select COUNT(*) AS count,tid from '.$this->db.' where tid=16 and '.$w);
		//print_r($f);
		echo $f[0]['count'];


$this->syArgs('year') 是年份

tid 是栏目的id


html写法

记录时间

<li data-year="{fun date('Y',$v['addtime'])}"><li>


js

$(function(){
 
			 
			 var s = '';
			 $('#list li').each(function(i){
				 console.log(i);
				 year = $(this).data('year');
			     num = $('[data-year="'+year+'"]').length;
				 if(year!=s){
					 _this = this;
					 $.ajax({
					 		type: "GET",
					 		url: 'index.php?c=article&a=yearnum',
					 		async: false,
					 		cache: false,
					 		data: {year:year},
					 		success: function(num){
					 			$(_this).before('<li class="tits"><h2>'+year+'</h2><span>共'+num+'场展览</span></li>');
					 		}
					 	});
					 
				 }
				 s = year;
				 
			 })
			 
			 
    	 })