用过动网论坛的朋友都知道,查看贴子时,用户信息那一块有一个小图标,显示的是发贴用户的星座。让每一个用户在注册时填写好自己的星座是不现实的,大家都是懒人,能填上生日就不错了,幸好,我们可以通过生日来计算出星座来,先看下面这一段程序,这可以从动网论坛的程序中提出来的:
<%
function astro(birthday)
on error resume next
dim birth,birthmonth
birth=day(birthday)
birthmonth=month(birthday)
select case birthmonth
case 1
if birth>=21 then
astro="

"
else
astro="

"
end if
case 2
if birth>=20 then
astro="

"
else
astro="

"
end if
case 3
if birth>=21 then
astro="

"
else
astro="

"
end if
case 4
if birth>=21 then
astro="

"
else
astro="

"
end if
case 5
if birth>=22 then
astro="

"
else
astro="

"
end if
case 6
if birth>=22 then
astro="

"
else
astro="

"
end if
case 7
if birth>=23 then
astro="

"
else
astro="

"
end if
case 8
if birthday>=24 then
astro="

"
else
astro="

"
end if
case 9
if birth>=24 then
astro="

"
else
astro="

"
end if
case 10
if birth>=24 then
astro="

"
else
astro="

"
end if
case 11
if birth>=23 then
astro="

"
else
astro="

"
end if
case 12
if birth>=22 then
astro="

"
else
astro="

"
end if
case else
astro=""
end select
end function
%>
这一段程序该怎么用呢?呵呵,先把它复制到你的站点中去,取名birthday.asp,然后将其包含进你想显示用户名的页面中,,现在假使你的用户记录集为Reuserlist,而用户生日保存在birthday字段中,那么,在想显示星座图片的地方加入如下代码就行了:
<% if Reuserlist.Fields.Item("birthday").value<>"" then
userbirth=astro(Reuserlist.Fields.Item("birthday").value)
response.write ""&userbirth&""
end if %>
在动网论坛里把star那个文件夹复制过来,粘贴到自己网站的images文件夹下,就可以浏览了,是不是也显示出对应的星座图片来了?如果图片没有正确显示出来,请检查birthday.asp文件中的图片文件路径。