asp 生日提醒

asp 生日提醒,第1张

数据库名:data.mdb

表名:employee

字段

ID 自动编号

EmployeeName 文本

DepartmentID 数字

Birthday 日期/时间

- - - - - - - - - - - -

asp代码:

<%

remindDays = 7 '提醒日期

set conn = Server.CreateObject("ADODB.Connection")

connstr="Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &Server.MapPath("data.mdb")

conn.Open connstr

sql = "select * from employee where datediff('d', cstr(year(date())) + '-' + cstr(month(Birthday)) + '-' + cstr(day(Birthday)),date())<=" &remindDays &" and datediff('d', cstr(year(date())) + '-' + cstr(month(Birthday)) + '-' + cstr(day(Birthday)),date())>=0 order by ID desc"

set rs = conn.execute(sql)

if not rs.eof then

response.write("近" &remindDays &"天过生日的员工:<br />")

do while not rs.eof

response.Write("-----------------------------------<br />")

response.Write("姓名:" &rs("EmployeeName") &"<br />")

response.Write("生日:" &rs("Birthday") &"<br />")

rs.movenext

loop

else

response.write("近" &remindDays &"天没有过生日的员工")

end if

rs.close

set rs =nothing

%>

----------------------------------------------------------------

<%

set conn = Server.CreateObject("ADODB.Connection")

connstr="Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &Server.MapPath("data.mdb")

conn.Open connstr

sql = "select * from employee where datediff('d', cstr(year(date())) + '-' + cstr(month(Birthday)) + '-' + cstr(day(Birthday)),date())=0 order by ID desc"

set rs = conn.execute(sql)

if not rs.eof then

response.write("今天过生日的员工:<br />")

do while not rs.eof

response.Write("姓名:<span style=""color:#f00"">" &rs("EmployeeName") &"</span>——"&rs("DepartmentID")&"<br />")

rs.movenext

loop

else

response.write("今天没有过生日的员工")

end if

rs.close

set rs =nothing

%>

3.不冲突,连接字符串写对了就行

是否可以解决您的问题?

分类: 电脑/网络 >>程序设计 >>其他编程语言

问题描述:

表:user

列:name,userinfo

userinfo:

email|homepage|1983-09-13|qq

应教下,如何修改下面的代码??求会员生日!!!谢谢了

<table width='100%' height=2><tr><td></td></tr></table>

<%

rem 用户生日

dim age

dim birthuser,birthnum

dim birthday

birthnum=0

'on error resume next

set rs=conn.execute("select username,birthday from [user_data]")

do while not rs.eof

if rs(1)="" then

rs.movenext

elseif month(rs(1))<>month(now()) or day(rs(1))<>day(now()) then

rs.movenext

else

if isdate(rs(1)) then

age=datediff("yyyy",rs(1),Now())

birthday=birthday &"<a href=user_view?username="&rs(0)&" title=祝"&age&"岁生日快乐! target=_blank>〖祝 "&rs(0)&"生日快乐 <img src=images/birthday.gif align=ab *** iddle border=0>〗</a>"

birthnum=birthnum+1

end if

rs.movenext

end if

loop

rs.close

if birthnum=0 then

birthday="<font color=#FF0000>※今天没有会员过生日※</font>"

end if

set rs=nothing

%>

<table border=1 width='98%' cellspacing=1 cellpadding=1 bgcolor=#000000 bordercolor=#FFFFFF>

<tr <%response.write forum_table2%>>

<td><%response.write img_ *** all("fk4") %><font class=end><b>今天过生日的会员(共 <%=birthnum%>人)</b></font></td>

</tr>

<tr<%response.write forum_table4%>>

<td align=center height=30><%=birthday%></td>

</tr>

</table>

解析:

1、取当前时间

取当前时间的第五位向后的数字组成字符(如:2000-1-1,那么组成后的为1-1)

2、取会员生日

取数据库中会员的生日取第五位后的数字组成字符

3、比较两种取值的结果是否相同,相同为生日

修改如下:(追答完整修改了)

do while not rs.eof 

    if xx="" then xx=rs("EmployeeName") else xx=xx&"、"&rs("EmployeeName") '只需要获取过生日人的名字就可以,多个名字用顿号隔开

rs.movenext 

loop 

response.Write("<span style=""color:#f00"">" & xx & "</span> 的生日!祝您生日快乐!健康幸福!!""<br />")


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11292097.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存