主题:多表查询问题!!!!
1,在下面的代码中,一个条件输入就可以找到检索的东西,组合起来就不行,然后是,首先载入的专家列表时空白,然后点击《抽取专家》按钮,实现抽取专家的功能。
2,在专家列表,如何将复选框选中的专家添加在项目的参与专家<expert>表中,专家的分隔符号又怎么实现,添加专家的总实现功能是在《保存并通知》按钮。
3《保存并通知》按钮的点击连接是否直接将专家的某个个人专有比如说《身份证》,直接插入到expert中就行了?
4,上半部分的抽取专家 和下面的专家列表信息是否要两个表单来实现。
代码如下:
<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<h3 align="center"><img src="images/w.gif" width="18" height="18" />抽取专家</h3>
<table width="385" height="247" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
[color=FF0000] <td height="245"><form action="xmzj.asp" method="get">
<%
xm=trim(request("xm"))
sex=trim(request("sex"))
sfzhm=trim(request("sfzhm"))
sjhm=trim(request("sjhm"))
gzsd=trim(request("gzsd"))
hylb=trim(request("hylb"))
sql="select id,xm,sex,sfzhm,sjhm,gzdw,hylb,Email from expert where 1=1"
if xm<>""then
sql=sql&" xm like '%"&xm&"%' "
end if
if sex<>""then
sql=sql&" and sex = '"&sex&"'"
end if
if shzhm<>"" then
sql=sql&" and sfzhm = '"&sfzhm&"'"
end if
if gzsd<>"" then
sql=sql&" and gzdw like '%"&gzsd&"%'"
end if
if hylb<>"" then
sql=sql&" and hylb = '"&hylb&"'"
end if
sql=sql&" order by id desc" &order
%>[/color]
<table width="870" height="270" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="41"colspan="6" bgcolor="#efeff7"><div align="center">符合条件的专家</div></td>
</tr>
<tr>
<td width="72" height="39">姓名
<label>:</label></td>
<td width="129"><label>
<input name="xm" type="text" id="xm" size="15" />
</label></td>
<td width="118"><div align="right">性别:</div></td>
<td width="261"><label>
<select name="sex" size="1" id="sex">
<option>全部</option>
<option value="男">男</option>
<option value="女">女</option>
</select>
</label></td>
<td width="80">行业类别</td>
<td width="185"><label>
<select name="hylb" size="1" id="hylb">
<option>全部</option>
</select>
</label></td>
</tr>
<tr>
<td height="40"><label></label>
技术职称</td>
<td><label>
<select name="jszc" size="1" id="jszc">
<option>全部</option>
</select>
</label></td>
<td><div align="right">专业资格</div></td>
<td><label>
<select name="zyzg" size="1" id="zyzg">
<option>全部</option>
</select>
</label></td>
<td>工作属地</td>
<td><label>
<select name="dwsd" size="1" id="dwsd">
<option>全部</option>
</select>
</label></td>
</tr>
<tr>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"><input name="zjcq" type="submit" id="zjcq" value="抽取专家" /></td>
<td height="30" bgcolor="#efeff7"><div align="center">
<input type="reset" name="Submit2" value="清空" />
</div></td>
</tr>
<tr>
<td height="30" bgcolor="#efeff7"><div align="center">选择</div></td>
<td height="30" bgcolor="#efeff7">姓名</td>
<td height="30" bgcolor="#efeff7">性别</td>
<td height="30" colspan="2" bgcolor="#efeff7">工作单位</td>
<td height="30" bgcolor="#efeff7">Email</td>
</tr> <%
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize=10
If Not (rs.eof and rs.bof) Then
rs.pagesize=5 '定义每页显示的记录数
pages=clng(Request("pages")) '获得当前页数
If pages<1 Then pages=1
If pages>rs.recordcount Then pages=rs.recordcount
showpage rs,pages '执行分页子程序showpage
Sub showpage(rs,pages) '分页子程序showpage(rs,pages)
rs.absolutepage=pages '指定指针所在的当前位置
For i=1 to rs.pagesize
%>
<tr>
<td height="30" bgcolor="#efeff7"><label>
<div align="center">
<input name="chk_id" type="checkbox" id="chk_id" value="expert" />
</div>
</label></td>
<td height="30" bgcolor="#efeff7"><%=rs("xm")%></td>
<td height="30" bgcolor="#efeff7"><%=rs("sex")%></td>
<td height="30" colspan="2" bgcolor="#efeff7"><%=rs("gzdw")%></td>
<td height="30" bgcolor="#efeff7"><%=rs("Email")%></td>
</tr>
<%
rs.movenext '指针向下移动
If rs.eof Then exit for
Next
End Sub
End If%>
<tr>
<td height="30" colspan="2" bgcolor="#efeff7"><div align="center">
<input name="chk_all" type="checkbox" id="chk_all" value="checkbox" onclick="CheckAll(this.form.chk_id,this.form.chk_all)"/>
全选/反选 </div></td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" colspan="2" bgcolor="#efeff7"><div align="center">
<%
if pages<>1 then
response.Write("&nbsp;&nbsp;<a href="&path&"?pages=1>首页</a>")
response.Write("&nbsp;&nbsp;<a href="&path&"?pages="&(pages-1)&">上一页</a>")
end if
response.Write("&nbsp;&nbsp;当前 <font color='#FF0000'>"&pages&"/"&rs.pagecount&"</font> 页")
if pages<>rs.pagecount then
response.Write("&nbsp;&nbsp;<a href="&path&"?pages="&(pages+1)&">下一页</a>")
response.Write("&nbsp;&nbsp;<a href="&path&"?pages="&rs.pagecount&">末页</a>")
end if
rs.close
Set rs=Nothing
%>
</div></td>
<td height="30" bgcolor="#efeff7"></td>
</tr>
<tr>
<td height="30" colspan="2" bgcolor="#efeff7"><label> </label>
<div align="center"></div></td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" colspan="2" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"><label>
<input name="tz" type="submit" id="tz" value="保存并通知" onclick="location='xmzj.asp'"/>
</label></td>
</tr>
</table>
</form>
</table>
<script language="javascript">
function CheckAll(elementsA,elementsB)
{
var len = elementsA;
if(len.length > 0)
{
for(i=0;i<len.length;i++)
{
elementsA[i].checked = true;
}
if(elementsB.checked ==false)
{
for(j=0;j<len.length;j++)
{
elementsA[j].checked = false;
}
}
}
else
{
len.checked = true;
if(elementsB.checked == false)
{
len.checked = false;
}
}
}
</script>
2,在专家列表,如何将复选框选中的专家添加在项目的参与专家<expert>表中,专家的分隔符号又怎么实现,添加专家的总实现功能是在《保存并通知》按钮。
3《保存并通知》按钮的点击连接是否直接将专家的某个个人专有比如说《身份证》,直接插入到expert中就行了?
4,上半部分的抽取专家 和下面的专家列表信息是否要两个表单来实现。
代码如下:
<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<h3 align="center"><img src="images/w.gif" width="18" height="18" />抽取专家</h3>
<table width="385" height="247" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
[color=FF0000] <td height="245"><form action="xmzj.asp" method="get">
<%
xm=trim(request("xm"))
sex=trim(request("sex"))
sfzhm=trim(request("sfzhm"))
sjhm=trim(request("sjhm"))
gzsd=trim(request("gzsd"))
hylb=trim(request("hylb"))
sql="select id,xm,sex,sfzhm,sjhm,gzdw,hylb,Email from expert where 1=1"
if xm<>""then
sql=sql&" xm like '%"&xm&"%' "
end if
if sex<>""then
sql=sql&" and sex = '"&sex&"'"
end if
if shzhm<>"" then
sql=sql&" and sfzhm = '"&sfzhm&"'"
end if
if gzsd<>"" then
sql=sql&" and gzdw like '%"&gzsd&"%'"
end if
if hylb<>"" then
sql=sql&" and hylb = '"&hylb&"'"
end if
sql=sql&" order by id desc" &order
%>[/color]
<table width="870" height="270" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="41"colspan="6" bgcolor="#efeff7"><div align="center">符合条件的专家</div></td>
</tr>
<tr>
<td width="72" height="39">姓名
<label>:</label></td>
<td width="129"><label>
<input name="xm" type="text" id="xm" size="15" />
</label></td>
<td width="118"><div align="right">性别:</div></td>
<td width="261"><label>
<select name="sex" size="1" id="sex">
<option>全部</option>
<option value="男">男</option>
<option value="女">女</option>
</select>
</label></td>
<td width="80">行业类别</td>
<td width="185"><label>
<select name="hylb" size="1" id="hylb">
<option>全部</option>
</select>
</label></td>
</tr>
<tr>
<td height="40"><label></label>
技术职称</td>
<td><label>
<select name="jszc" size="1" id="jszc">
<option>全部</option>
</select>
</label></td>
<td><div align="right">专业资格</div></td>
<td><label>
<select name="zyzg" size="1" id="zyzg">
<option>全部</option>
</select>
</label></td>
<td>工作属地</td>
<td><label>
<select name="dwsd" size="1" id="dwsd">
<option>全部</option>
</select>
</label></td>
</tr>
<tr>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"><input name="zjcq" type="submit" id="zjcq" value="抽取专家" /></td>
<td height="30" bgcolor="#efeff7"><div align="center">
<input type="reset" name="Submit2" value="清空" />
</div></td>
</tr>
<tr>
<td height="30" bgcolor="#efeff7"><div align="center">选择</div></td>
<td height="30" bgcolor="#efeff7">姓名</td>
<td height="30" bgcolor="#efeff7">性别</td>
<td height="30" colspan="2" bgcolor="#efeff7">工作单位</td>
<td height="30" bgcolor="#efeff7">Email</td>
</tr> <%
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize=10
If Not (rs.eof and rs.bof) Then
rs.pagesize=5 '定义每页显示的记录数
pages=clng(Request("pages")) '获得当前页数
If pages<1 Then pages=1
If pages>rs.recordcount Then pages=rs.recordcount
showpage rs,pages '执行分页子程序showpage
Sub showpage(rs,pages) '分页子程序showpage(rs,pages)
rs.absolutepage=pages '指定指针所在的当前位置
For i=1 to rs.pagesize
%>
<tr>
<td height="30" bgcolor="#efeff7"><label>
<div align="center">
<input name="chk_id" type="checkbox" id="chk_id" value="expert" />
</div>
</label></td>
<td height="30" bgcolor="#efeff7"><%=rs("xm")%></td>
<td height="30" bgcolor="#efeff7"><%=rs("sex")%></td>
<td height="30" colspan="2" bgcolor="#efeff7"><%=rs("gzdw")%></td>
<td height="30" bgcolor="#efeff7"><%=rs("Email")%></td>
</tr>
<%
rs.movenext '指针向下移动
If rs.eof Then exit for
Next
End Sub
End If%>
<tr>
<td height="30" colspan="2" bgcolor="#efeff7"><div align="center">
<input name="chk_all" type="checkbox" id="chk_all" value="checkbox" onclick="CheckAll(this.form.chk_id,this.form.chk_all)"/>
全选/反选 </div></td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" colspan="2" bgcolor="#efeff7"><div align="center">
<%
if pages<>1 then
response.Write("&nbsp;&nbsp;<a href="&path&"?pages=1>首页</a>")
response.Write("&nbsp;&nbsp;<a href="&path&"?pages="&(pages-1)&">上一页</a>")
end if
response.Write("&nbsp;&nbsp;当前 <font color='#FF0000'>"&pages&"/"&rs.pagecount&"</font> 页")
if pages<>rs.pagecount then
response.Write("&nbsp;&nbsp;<a href="&path&"?pages="&(pages+1)&">下一页</a>")
response.Write("&nbsp;&nbsp;<a href="&path&"?pages="&rs.pagecount&">末页</a>")
end if
rs.close
Set rs=Nothing
%>
</div></td>
<td height="30" bgcolor="#efeff7"></td>
</tr>
<tr>
<td height="30" colspan="2" bgcolor="#efeff7"><label> </label>
<div align="center"></div></td>
<td height="30" bgcolor="#efeff7"> </td>
<td height="30" colspan="2" bgcolor="#efeff7"> </td>
<td height="30" bgcolor="#efeff7"><label>
<input name="tz" type="submit" id="tz" value="保存并通知" onclick="location='xmzj.asp'"/>
</label></td>
</tr>
</table>
</form>
</table>
<script language="javascript">
function CheckAll(elementsA,elementsB)
{
var len = elementsA;
if(len.length > 0)
{
for(i=0;i<len.length;i++)
{
elementsA[i].checked = true;
}
if(elementsB.checked ==false)
{
for(j=0;j<len.length;j++)
{
elementsA[j].checked = false;
}
}
}
else
{
len.checked = true;
if(elementsB.checked == false)
{
len.checked = false;
}
}
}
</script>