怎么根据查询出的信息为条件查询同条件信息
时间:2011-06-11
来源:互联网
表名字:abc
字段名: id chengshi name
字段数据:id: 1,chengshi:成都市 ,name:张三
字段数据:id: 2,chengshi:成都市 ,name:李四
字段数据:id: 3,chengshi:成都市 ,name:赵二
字段数据:id: 4,chengshi:北京市 ,name:王当
字段数据:id: 5,chengshi:北京市 ,name:邱雨
字段数据:id: 6,chengshi:天津市 ,name:何东
字段数据:id: 7,chengshi:天津市 ,name:张四
字段数据:id: 8,chengshi:天津市 ,name:张五
字段数据:id: 9,chengshi:成都市 ,name:张六
字段数据:id: 10,chengshi:成都市 ,name:张七
数据库假设有这么10条信息
现在我第一步假设id=2根据ID读取信息应该是 id 2 城市:成都市 姓名:李四
第一段代码根据传递id过来的代码<%
id=request.QueryString("id")
if id="" or not isnumeric(id) then
Response.Write "<script>alert('参数错误!');history.go(-1);</script>"
Response.End()
end if
exec="select * from abc where id="&id
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
if rs.eof and rs.bof then
Response.Write "<script>alert('参数不正确,ID值不存在!');history.go(-1);</script>"
Response.End()
end if
%>
上面第一步玩; 下面做最重要我不懂的问题了
此处一万字没时间写
呵呵上面玩笑了哪有什么字
说重点上面我们不是根据ID查询出第2条记录了(id 2 城市:成都市 姓名:李四
)现在我们要根据这条记录的城市名称查询出这个城市的人员名字
sql1 = "select * from [abc] where chengshi="&rs("chengshi")&" order by id desc"
set rs1=server.createobject("adodb.recordset")
rs1.open exec,conn,1,1
if rs1.eof and rs1.bof then
Response.Write "<script>alert('参数不正确,ID值不存在!');history.go(-1);</script>"
Response.End()
end if
%> <%=rs1("name")%>
就应该是 城市:成都市, 姓名:张三
城市:成都市 ,姓名:李四
城市:成都市 ,姓名:赵二
城市:成都市 ,姓名:张六
城市:成都市 ,姓名:张七
请高手们指点一万字内容
字段名: id chengshi name
字段数据:id: 1,chengshi:成都市 ,name:张三
字段数据:id: 2,chengshi:成都市 ,name:李四
字段数据:id: 3,chengshi:成都市 ,name:赵二
字段数据:id: 4,chengshi:北京市 ,name:王当
字段数据:id: 5,chengshi:北京市 ,name:邱雨
字段数据:id: 6,chengshi:天津市 ,name:何东
字段数据:id: 7,chengshi:天津市 ,name:张四
字段数据:id: 8,chengshi:天津市 ,name:张五
字段数据:id: 9,chengshi:成都市 ,name:张六
字段数据:id: 10,chengshi:成都市 ,name:张七
数据库假设有这么10条信息
现在我第一步假设id=2根据ID读取信息应该是 id 2 城市:成都市 姓名:李四
第一段代码根据传递id过来的代码<%
id=request.QueryString("id")
if id="" or not isnumeric(id) then
Response.Write "<script>alert('参数错误!');history.go(-1);</script>"
Response.End()
end if
exec="select * from abc where id="&id
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
if rs.eof and rs.bof then
Response.Write "<script>alert('参数不正确,ID值不存在!');history.go(-1);</script>"
Response.End()
end if
%>
上面第一步玩; 下面做最重要我不懂的问题了
此处一万字没时间写
呵呵上面玩笑了哪有什么字
说重点上面我们不是根据ID查询出第2条记录了(id 2 城市:成都市 姓名:李四
)现在我们要根据这条记录的城市名称查询出这个城市的人员名字
sql1 = "select * from [abc] where chengshi="&rs("chengshi")&" order by id desc"
set rs1=server.createobject("adodb.recordset")
rs1.open exec,conn,1,1
if rs1.eof and rs1.bof then
Response.Write "<script>alert('参数不正确,ID值不存在!');history.go(-1);</script>"
Response.End()
end if
%> <%=rs1("name")%>
就应该是 城市:成都市, 姓名:张三
城市:成都市 ,姓名:李四
城市:成都市 ,姓名:赵二
城市:成都市 ,姓名:张六
城市:成都市 ,姓名:张七
请高手们指点一万字内容
作者: wutengchu 发布时间: 2011-06-11
没看明白你要表达啥啊?
作者: ice241018 发布时间: 2011-06-12
where chengshi='"&rs("chengshi")&"'
作者: tcwsyt 发布时间: 2011-06-12
你的问题到底是什么 没搞清楚
作者: ma1986 发布时间: 2011-06-12
你是要循环显示内容吗?
<%
set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from [abc] where chengshi='"&rs("chengshi")&"' order by id desc",conn,1,3
if rs1.eof and rs1.bof then
Response.Write "<script>alert('参数不正确,ID值不存在!');history.go(-1);</script>"
Response.End()
%><table width="100%" border="0" cellpadding="0" cellspacing="0" class="zl-121">
<%do while not rs1.eof%>
<tr>
<td align="left" class="h3">城市</td>
<td align="left" class="h3">姓名</td>
</tr>
<tr>
<td align="left" class="h3"><%=rs1("chengshi")%></td>
<td align="left" class="h3"><%=rs1("name")%></td>
</tr>
<%
rs1.movenext
loop
%>
</table>
<%
set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from [abc] where chengshi='"&rs("chengshi")&"' order by id desc",conn,1,3
if rs1.eof and rs1.bof then
Response.Write "<script>alert('参数不正确,ID值不存在!');history.go(-1);</script>"
Response.End()
%><table width="100%" border="0" cellpadding="0" cellspacing="0" class="zl-121">
<%do while not rs1.eof%>
<tr>
<td align="left" class="h3">城市</td>
<td align="left" class="h3">姓名</td>
</tr>
<tr>
<td align="left" class="h3"><%=rs1("chengshi")%></td>
<td align="left" class="h3"><%=rs1("name")%></td>
</tr>
<%
rs1.movenext
loop
%>
</table>
作者: ice241018 发布时间: 2011-06-12
上面代码还少一个<%end if%>
作者: ice241018 发布时间: 2011-06-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28