欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp实现的可以提醒生日的几种方法附代码

程序员文章站 2022-04-14 19:14:18
asp生日自动提醒小程式 用asp编写,调试通过,使用方便-asp birthday automatically remind small programs with th...
asp生日自动提醒小程式 用asp编写,调试通过,使用方便-asp birthday automatically remind small programs with the preparation of asp, debug, easy to use
方法一:

最初写的一个用于班级网站的最近一个月同学生日的提醒小程序。虽然不怎么样,而且很乱,但是最起码是自己动脑筋去想的,所以我比较看重。asp程序虽然有好多可以借鉴人家的。但是我想更多时候,我们应该在经典上有所突出,有所创新那不至于默守陈规而无永远只能做一个平凡的程序员。

<%
      dim     daydif
      dim     days '定义查询前后多少天内生日的同学,如60则查询前一个月后下一个月生日的同学名单。
      sql="select name,brithday from class "
            set rs=server.createobject("adodb.recordset")
            rs.open sql,con,1,1
            for i=1 to rs.recordcount     '读出所有的数据 
                    if rs.eof then exit for
                    daydif=abs(datediff("d",date,rs("birthday")) )mod 365
                    if daydif < days  
                          response.write rs("name")%> 
                          response.write "<font color="#ff0000">" 
                          response.write rs("birthday")&"、</font>"
                    end if
                    rs.movenext
            loop 
            rs.close
            set rs=nothing
            %>

方法二:
<%
days1=split(date(),"-")
days2=split(dateadd("d",5,date()),"-")
sql="select [id],memberid,birthday from customers "
if days1(1)<>days2(1) then
sql=sql+" where (month(birthday) = '"&days1(1)&"' or month(birthday)='"&days2(1)&"')"
else
sql=sql+" where month(birthday) = '"&days1(1)&"'"
end if
sql=sql+" and day(birthday) between '"&days1(2)&"' and '"&days2(2)&"'"
'response.write(sql)
set conn=server.createobject("adodb.connection")
conn.open connstr
set rs=conn.execute(sql)
if not rs.eof then%>
<script language="javascript"> 
window.onload = getmsg; 
window.onresize = resizediv; 
window.onerror = function(){} 
//短信提示使用(asilas添加) 
var divtop,divleft,divwidth,divheight,docheight,docwidth,objtimer,i = 0; 
function getmsg() 

try{ 
divtop = parseint(document.getelementbyid("emeng").style.top,10) 
divleft = parseint(document.getelementbyid("emeng").style.left,10) 
divheight = parseint(document.getelementbyid("emeng").offsetheight,10) 
divwidth = parseint(document.getelementbyid("emeng").offsetwidth,10) 
docwidth = document.body.clientwidth; 
docheight = document.body.clientheight; 
document.getelementbyid("emeng").style.top = parseint(document.body.scrolltop,10) + docheight + 10;// divheight 
document.getelementbyid("emeng").style.left = parseint(document.body.scrollleft,10) + docwidth - divwidth 
document.getelementbyid("emeng").style.visibility="visible" 
objtimer = window.setinterval("movediv()",10) 

catch(e){} 
}
function resizediv() 

i+=1 
if(i>500) closediv() 
try{ 
divheight = parseint(document.getelementbyid("emeng").offsetheight,10) 
divwidth = parseint(document.getelementbyid("emeng").offsetwidth,10) 
docwidth = document.body.clientwidth; 
docheight = document.body.clientheight; 
document.getelementbyid("emeng").style.top = docheight - divheight + parseint(document.body.scrolltop,10) 
document.getelementbyid("emeng").style.left = docwidth - divwidth + parseint(document.body.scrollleft,10) 

catch(e){} 
}
function movediv() 

try 

if(parseint(document.getelementbyid("emeng").style.top,10) <= (docheight - divheight + parseint(document.body.scrolltop,10))) 

window.clearinterval(objtimer) 
objtimer = window.setinterval("resizediv()",1) 

divtop = parseint(document.getelementbyid("emeng").style.top,10) 
document.getelementbyid("emeng").style.top = divtop - 1 

catch(e){} 

function closediv() 

document.getelementbyid('emeng').style.visibility='hidden'; 
if(objtimer) window.clearinterval(objtimer) 

</script> 
<div id=emeng style='border-right: #455690 1px solid; border-top: #a6b4cf 1px solid; z-index:99999; left: 0px; visibility: hidden; border-left: #a6b4cf 1px solid; width: 180px; border-bottom: #455690 1px solid; position: absolute; top: 0px; height: 116px; background-color: #c9d3f3'>
<table style='border-top: #ffffff 1px solid; border-left: #ffffff 1px solid' cellspacing=0 cellpadding=0 width='100%' bgcolor=#cfdef4 border=0><tbody>
<tr>
     <td style='font-size: 12px; background-image: url(msgtopbg.gif); color: #0f2c8c' width=30 height=24></td> 
     <td style='font-weight: normal; font-size: 12px; background-image: url(msgtopbg.gif); color: #1f336b; padding-top: 4px;padding-left: 4px' valign=center width='100%'> 生日提示:</td>
     <td style='background-image: url(msgtopbg.gif); padding-top: 2px;padding-right:2px' valign=center align=right width=19><span title=关闭 style='cursor: hand;color:red;font-size:12px;font-weight:bold;margin-right:4px;' onclick=closediv() >×</span><!-- <img title=关闭 style='cursor: hand' onclick=closediv() hspace=3 src='msgclose.jpg'> --></td> 
</tr> 
<tr>
     <td style='padding-right: 1px; background-image: url(1msgbottombg.jpg); padding-bottom: 1px' colspan=3 height=90> <div style='border-right: #b9c9ef 1px solid; padding-right: 13px; border-top: #728eb8 1px solid; padding-left: 13px; font-size: 12px; padding-bottom: 13px; border-left: #728eb8 1px solid; width: 100%; color: #1f336b; padding-top: 18px; border-bottom: #b9c9ef 1px solid; height: 100%'>近期将要过生日的会员有:<br><br> <div align=center style='word-break:break-all'>
<%i=1
do while not rs.eof
response.write("<a href='/system/admmember/edit.asp?id="&rs(0)&"' title=''><font color='red'>"&rs(1)&"</font></a>("&month(rs(2))&"-"&day(rs(2))&")  ")
if i mod 2 =0 then response.write("</br>")
rs.movenext
i=i+1
loop%></div></div> </td>
</tr> 
</tbody> 
</table> 
</div> 
<% end if
rs.close
set rs=nothing 
conn.close()
set conn=nothing %> 

 
方法三:
sql server:
<%
if month(now())=12 and day(now())>24 then
ssql = "select foodid, strname, timeid from tfood where ( datediff(d,getdate(),dateadd(year,datediff(year,timeid,getdate()),timeid))<=200 and datediff(d,getdate(),dateadd(year,datediff(year,timeid,getdate()),timeid))>=0 ) or ( datediff(d,getdate(),dateadd(year,datediff(year,timeid,getdate())+1,timeid))<=200 and datediff(d,getdate(),dateadd(year,datediff(year,timeid,getdate())+1,timeid))>=0 )"
else
ssql = "select foodid, strname, timeid from tfood where ( datediff(d,getdate(),dateadd(year,datediff(year,timeid,getdate()),timeid))<=200 and datediff(d,getdate(),dateadd(year,datediff(year,timeid,getdate()),timeid))>=0 )"
end if
%>
access:
<%
if month(now())=12 and day(now())>24 then
    ssql = "select *
from customers
where ( datediff('d',date(),dateadd('yyyy',datediff('yyyy',birthday,date()),birthday))<=5 and datediff('d',date(),dateadd('yyyy',datediff('yyyy',birthday,date()),birthday))>=0 ) or ( datediff('d',date(),dateadd('yyyy',datediff('yyyy',birthday,date())+1,birthday))<=5 and datediff('d',date(),dateadd('yyyy',datediff('yyyy',birthday,date())+1,birthday))>=0 );"
    else
     ssql = "select *
from customers
where (datediff('d',date(),dateadd('yyyy',datediff('yyyy',[birthday],date()),[birthday]))<=5 and datediff('d',date(),dateadd('yyyy',datediff('yyyy',[birthday],date()),[birthday]))>=0);"
end if
%>