现在的位置: 首页 > 综合 > 正文

banner_list.jsp 下拉框筛选 @

2013年08月29日 ⁄ 综合 ⁄ 共 7734字 ⁄ 字号 评论关闭

<%@ page language="java"  contentType="text/html; charset=GB2312" import="java.sql.*"%>
<jsp:useBean id="db" class="com.pp.db.DBOperation"></jsp:useBean>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%! 
 //每页显示的记录数
 int pageSize = 10;
 //总页数
 int pageCount = 0;
 //总记录数
 int rowCount=0;
 //当前页
 int showPage=1;
 
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP './advertiser/banner_list.jsp' starting page</title>
   
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <link rel="stylesheet" type="text/css" href="./css/style.css">
<script type="text/javascript">
function send(select){
var ID=select.options[select.selectedIndex].value;
if(ID!=0)
window.location.href="banner_list.jsp?ID="+ID;
else
{window.location.href="banner_list.jsp?";
}
}

</script>
  </head>
 
  <body>
 <FIELDSET
            style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px"><LEGEND><SPAN
            class=f1>广告列表</SPAN></LEGEND>
            <TABLE class=middle1 cellSpacing=0 cellPadding=0 width="100%"
            align=left border=0>
              <TBODY>
              <tr>
              <td colspan="15">
              广告项目
              <SELECT class=input1 id="sel" size=1 name="ads_project_ID" onchange="send(this)" >
                 <option value="0">选择全部</option>
                <%
                 int ID=0;
                   if(request.getParameter("ID")!=null)
                {
                  ID=Integer.parseInt(request.getParameter("ID"));
                }
             
              
               
                db.creatConnection();
                ResultSet rs=null;
                ResultSet rs2=null;
                ResultSet rs3=null;
                ResultSet rs4=null;
                rs= db.executeQuery("select * from ads_project");
                while(rs.next())
                { int  ads_project_ID=rs.getInt("id");
                   String projectName=rs.getString("title");
               %>
                <option value="<%=ads_project_ID %>"
                <%
                 if(ads_project_ID==ID){
                 %>
                 selected
                <%} %>
               
                 ><%=projectName %></option>
               <%
                 }
            
                 %>
               </SELECT>
              </td>
               </tr>
            
                 <TR>
                <TD><B>ID</B></TD>
                <TD noWrap><B>所属广告项目</B></TD>
                <TD><B>名称</B></TD>
                <TD><B>类型</B></TD>
             
              
                <TD noWrap><B>发布日期</B></TD>
                <TD noWrap><B>链接地址</B></TD>
                <TD><B>总量</B></TD>
                <TD noWrap colSpan=3><B>操作</B></TD></TR>
             
             
             
             
             
             
               <%
             
                String title="";
                int type_id;
                String type="";
                int mount;
                String pic="";
                String url="";
                String intro="";
                int ads_project_ID;
                String releasetime="";
              
              
                if(request.getParameter("ID")==null)
                {
                  rs2= db.executeQuery("select * from ads_des");
                }
                 else{
                
                 rs2= db.executeQuery("select * from ads_des where ads_project_ID="+ID);
                }
               rs2.last();
   //获取记录总数.
   rowCount = rs2.getRow();       
   //总页数的计算公式
   pageCount = (rowCount % pageSize == 0) ? (rowCount / pageSize ) : (rowCount / pageSize +1);
   
   //取得用户所指定要显示的页
   String goToPage = request.getParameter("showPage");
   if (goToPage == null)
   {
    goToPage = "1";
   }
  
   //将当前要显示的页码转换成整型
   try
   {
    showPage = Integer.parseInt(goToPage);
   }
   catch (NumberFormatException ex)
   {
    showPage = 1;
   }
  
   //当前页小于等于第一页,则按第一页算;如果当前页大于等于总页数,则为最后页
   if(showPage <= 1)
   {
    showPage = 1;
   }
   else if(showPage >= pageCount)
   {
    showPage =  pageCount;
   }
  
   //游标的位置 (当前页 - 1) * 页面大小 + 1
   int posion = (showPage -1 ) * pageSize + 1;
   //设置游标的位置
   rs2.absolute(posion);
   int i =0;
      //循环显示表中的数据 pageSize(每页所显示的记录)
      //rs2.isAfterLast() 游标是否在最后一行之后 说明后面已经没记录
      while(i<pageSize && !rs2.isAfterLast())
{
                int id=rs2.getInt("id");
             //   System.out.println(id);
                 title=rs2.getString("title");
                 // System.out.println(title);
                type_id=rs2.getInt("type_id");
                    rs4= db.executeQuery("select type from ads_type where type_id="+type_id);
                  if(rs4.next()){
                   type=rs4.getString("type");
                  // System.out.println("type:"+type);
                   }
                mount=rs2.getInt("mount");
               // pic=rs2.getString("pic");
                url=rs2.getString("url");
                //intro=rs.getString("intro");
                ads_project_ID=rs2.getInt("ads_project_ID");
                releasetime =rs2.getDate("releasetime").toString();
                  rs3= db.executeQuery("select title from ads_project where id="+ads_project_ID);
               String projectName="";
               if(rs3.next()){
                 projectName=rs3.getString("title");
                 }         //项目名称
               %>
             
         
              <TR>
                <TD><%=id %></TD>
                <TD><%=projectName %></TD>
                <TD><%=title %></TD>
                <TD><%=type %></TD>
              
                <TD><%=releasetime %></TD>
                <TD><%=url %></TD>
                <TD><%=mount %></TD>
                <TD><A onclick="return preview('973');"
                  href="./advertiser/./advertiser/banner_list.jsp#">查看</A></TD>
                <TD><A
                  href="./advertiser/banner_edit.jsp?banner_id=973">修改</A></TD>
                <TD><A onclick="return quantity('973')"
                  href="./advertiser/./advertiser/banner_list.jsp#">增加投放量</A></TD></TR>
                 
                      <%
                 rs2.next();
     i++;
  
                  
      }

  

                   rs.close();
                rs2.close();
                rs3.close();
                  rs4.close();
              
                db.closeConnection();
             
            
                 %>
                 
                 
            
                 
                 
                 
                 
              <TR>
                   <TD class=nav colSpan=14><form action="./advertiser/banner_list.jsp" method="post" target="_self">
   共<font color=red><%=rowCount%></font>条&nbsp;
   <font color=red><%=pageSize%></font>条/页&nbsp;
   第<font color=red><%=showPage%></font>页/共<font color=red><%=pageCount%></font>页 &nbsp;
   <a href="./advertiser/banner_list.jsp?showPage=1" target="_self">[首页]</a>&nbsp; 
   <%
    //判断“上一页”链接是否要显示
    if(showPage > 1)
    {   
   %>
     <a href="./advertiser/banner_list.jsp?showPage=<%=showPage-1%>" target="_self">[上一页]</a>&nbsp;&nbsp;
   <%
    }
    else
    {
   %>
     [上一页]&nbsp;
   <%
    }
    //判断"下一页"链接是否要显示
    if(showPage < pageCount)
    {   
   %>
     <a href="./advertiser/banner_list.jsp?showPage=<%=showPage+1%>" target="_self">[下一页]</a>&nbsp;
   <%
    }
    else
    {
   %>
     [下一页]&nbsp;
   <%
    }
   %>
   <a href="./advertiser/banner_list.jsp?showPage=<%=pageCount%>" target="_self">[尾页]</a>&nbsp;
   转到
   <select name="showPage">
   <%
    for(int x=1;x<=pageCount;x++)
    {
   %>
     <option value="<%=x%>" <%if(showPage==x) out.println("selected");%> ><%=x%></option>
   <%
    }
   %>
   </select>  
   页&nbsp;
   <input type="submit" name="go" value="提交"/>
   </form></TD>
              
              
              
              
              
              
              
              
              
              
             </TR> 
              
               </TBODY></TABLE></FIELDSET>
  </body>
</html>
 

抱歉!评论已关闭.