统计每个部门的人数
dept是部门表,member是成员表,d_number部门编号,它是dept和member表中的属性,我想在这个页面中统计每个部门的人数<!--#include file="conn.asp"-->
<%
set rst=server.createobject("adodb.recordset")
sql="select * from dept"
rst.open sql,conn,1,1
%>
<html>
<head>
<title>部门</title>
<style type="text/css">
<!--
.STYLE3 {font-size: x-large}
-->
</style>
</head>
<body>
<%
if Not(rst.bof and rst.eof) then'判别数据表中是否为空记录
NumRecord=rst.recordcount
rst.pagesize=10
NumPage=rst.Pagecount
if request("page")=empty then
NoncePage=1
else
if Cint(request("page"))<1 then
NoncePage=1
else
NoncePage=request("page")
end if
if Cint(Trim(request("page")))>Cint(NumPage) then NoncePage=NumPage
end if
else
NumRecord=0
NumPage=0
NoncePage=0
end if
%>
<div align="center"><img src="image/title.jpg">
<span class="STYLE3">部门管理</span></div>
<table width="100%" border="1">
<tr>
<td width="14%" align="center" bgcolor="#FFFFCC">部门编号</td>
<td width="14%" align="center" bgcolor="#FFFFCC">部门名称</td>
<td width="14%" align="center" bgcolor="#FFFFCC">部门地址</td>
<td width="14%" align="center" bgcolor="#FFFFCC">电话</td>
<td width="14%" align="center" bgcolor="#FFFFCC">人数</td>
<td width="14%" align="center" bgcolor="#FFFFCC">修改</td>
<td width="14%" align="center" bgcolor="#FFFFCC">删除</td>
</tr>
<%if Not(rst.bof and rst.eof) then
rst.move (Cint(NoncePage)-1)*10,1
for i=1 to rst.pagesize
%>
<tr>
<td align="center"><%=rst("d_number")%></td>
<td align="center"><%=rst("d_name")%></td>
<td align="center"><%=rst("adress")%></td>
<td align="center"><%=rst("phone")%></td>
<td align="center">
<% —
set rs=server.createobject("adodb.recordset") 这一段是进行统计的程序
sql="select count(*) from member where d_number='"<%=rst("d_number")%>"'" 但是这个不正确,请问要
rs.open sql,conn,1,1 怎样改,我是新手,希望
response.Write" count(*)" 高手别笑话我噢!!!
%> —
</td>
<td align="center"><a href="mod_dept.asp?d_number=<%=rst("d_number")%>">修改</a></td>
<td align="center"><a href="del_dept.asp?d_number=<%=rst("d_number")%>">删除</a></td>
</tr>
<% rst.movenext
if rst.eof then exit for
next
else
response.write "<tr><td colspan=6><marquee scrolldelay=120 behavior=alternate>没有找到任何记录!!!</marquee></td></tr>"
end if
rst.close
set rst=nothing
%>
<table width="748" border="0" align="center">
<tr>
<td height="17">
<div align="right">
<input type="hidden" name="page" value="<%=NoncePage%>">
<%
if NoncePage>1 then
response.write "|<a href=dept_manege.asp?page=1>首 页</a>| |<a href=dept_manege.asp?page="&NoncePage-1&">上一页</a>| "
else
response.write "|首 页| |上一页| "
end if
if Cint(Trim(NoncePage))<Cint(Trim(NumPage)) then
response.write "|<a href=dept_manege.asp?page="&NoncePage+1&">下一页</a>| |<a href=dept_manege.asp?page="&NumPage&">尾 页</a>|"
else
response.write "|下一页| |尾 页|"
end if
%>
页次:<font color="#0033CC"><%=NoncePage%></font>/<font color="#0033CC"><%=NumPage%></font>
共<font color="#0033CC"><%=NumRecord%></font>条记录 </div>
</td>
</table>
</center>
</table>
<table width="100%">
<tr>
<td><div align="center"><a href="add_dept11.asp">添加新部门</a></div></td>
</tr>
</table>
</body>
</html>
</body>
</html>