内容显示页
 
类别:数据库+SQL | 浏览(247) | 2007-5-11 0:02:08

做blog时时里面要实现一个文章存档功能,调试了一会终于出来了,思路是:

1.第一层先找出都有哪些年,倒序排列

2.第二层统计第一层的年里的月分有多少个,从而得出:YY年MM月(N篇文章)

3.留言以感谢柳永法同志给大家共享代码

Set rsyear=Server.Createobject("Adodb.Recordset")
sql="select year(addtime) as y from BlogArticle group by year(addtime) order by year(addtime) desc "
rsyear.open sql,conn,1,1
do while not rsyear.eof
        Set rsmonth=Server.Createobject("Adodb.Recordset")
        sql="select count(*),month(addtime) from BlogArticle where year(addtime)="&rsyear(0)&" group by month(addtime)  order by month(addtime) desc "
        rsmonth.open sql,conn,1,1
        do while not rsmonth.eof
                content_temp=content
                content_temp=replace(content_temp,"$yearmonth$",rsyear(0) & rsmonth(1))
                content_temp=replace(content_temp,"$yearmonth2$",rsyear(0) & "年" & rsmonth(1) &"月")
                content_temp=replace(content_temp,"$yearno$",rsmonth(0))
                content_all=content_all & content_temp
        rsmonth.movenext
        loop
rsyear.movenext
loop


引用本页地址:http://www.yongfa365.com/item/8d43f88a471d6096.html
 
 
相关链接
 
网友评论:
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片 看不清? 换张图试试
 
     
 
 
文章分类
 
 
.Net + C#(73)
 
 
ASP+VBS(161)
 
 
 
Linux(10)
 
 
 
web 2.0(26)
 
 
 
 
 
心程(68)
 
生活(97)
 
 
     

Power by :柳永法(yongfa365)'Blog  | 京ICP备07011491号  QQ:64049027  E-mail:64049027@qq.com yongfa365'CodePlex yongfa365'CodeGoogle

申请友情链接 要求:跟本站主题相类似正规网站,双方交换为首页位置

转载请注明来源,以便后人及时得到最新、修正、加强版!!!