我在后台查询数据库得到一些值怎么赋值给页面的下拉框
1个回答
展开全部
sql="select ygbh,GETNAME(ygbh) as name from lz.db_user where qx='2' and inf ='工程师' and ygbh not in (select userid from lz.flow_task where type='权限剥夺') "
+" and ygbh in (select sendid from lz.flow_history where userid='"+ID+"')";
rt=st.executeQuery(sql);
%>
<body bgcolor=#b0e0e6>
<form action="b_down1.jsp">
<table border="0" align="center" width="664">
<tr>
<td height="2" width="134" class="unnamed1">
<div align="right">剥夺对象:</div>
</td>
<td width="520" height="2">
<select name="shenpi">
<%
int b=0;
while(rt.next()){
if(b==0){
%>
<option value="<%=rt.getString("ygbh")%>" selected="selected"><%=rt.getString("ygbh")%>-<%=rt.getString("name")%></option>
<%
b++; }else{
%>
<option value="<%=rt.getString("ygbh")%>"><%=rt.getString("ygbh")%>-<%=rt.getString("name")%></option>
<%
}
}
rt.close();
%>
</select>
</td>
</tr>
循环给option标签赋值即可,这个是我做过一个实例代码,可以参考下
+" and ygbh in (select sendid from lz.flow_history where userid='"+ID+"')";
rt=st.executeQuery(sql);
%>
<body bgcolor=#b0e0e6>
<form action="b_down1.jsp">
<table border="0" align="center" width="664">
<tr>
<td height="2" width="134" class="unnamed1">
<div align="right">剥夺对象:</div>
</td>
<td width="520" height="2">
<select name="shenpi">
<%
int b=0;
while(rt.next()){
if(b==0){
%>
<option value="<%=rt.getString("ygbh")%>" selected="selected"><%=rt.getString("ygbh")%>-<%=rt.getString("name")%></option>
<%
b++; }else{
%>
<option value="<%=rt.getString("ygbh")%>"><%=rt.getString("ygbh")%>-<%=rt.getString("name")%></option>
<%
}
}
rt.close();
%>
</select>
</td>
</tr>
循环给option标签赋值即可,这个是我做过一个实例代码,可以参考下
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询