Banner_list.jsp drop-down box filter @

Source: Internet
Author: User

<% @ 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 + "/";
%>
<%!
// Number of records displayed on each page
Int pagesize = 10;
// Total number of pages
Int pagecount = 0;
// Total number of records
Int rowcount = 0;
// Current page
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> ad list </span> </legend>
<Table class = middle1 cellspacing = 0 cellpadding = 0 width = "100%"
Align = left border = 0>
<Tbody>
<Tr>
<TD colspan = "15">
Ad Project
<Select class = input1 id = "Sel" size = 1 name = "ads_project_id" onchange = "Send (this)">
<Option value = "0"> select all </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.exe cutequery ("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> advertisement project </B> </TD>
<TD> <B> name </B> </TD>
<TD> <B> type </B> </TD>


<TD nowrap> <B> release date </B> </TD>
<TD nowrap> <B> link address </B> </TD>
<TD> <B> total </B> </TD>
<TD nowrap colspan = 3> <B> operation </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.exe cutequery ("select * From ads_des ");
}
Else {

Rs2 = db.exe cutequery ("select * From ads_des where ads_project_id =" + id );
}
Rs2.last ();
// Obtain the total number of records.
Rowcount = rs2.getrow ();
// Formula for calculating the total number of pages
Pagecount = (rowcount % pagesize = 0 )? (Rowcount/pagesize): (rowcount/pagesize + 1 );

// Obtain the page to be displayed by the user
String gotopage = request. getparameter ("showpage ");
If (gotopage = NULL)
{
Gotopage = "1 ";
}

// Convert the current page number to an integer
Try
{
Showpage = integer. parseint (gotopage );
}
Catch (numberformatexception ex)
{
Showpage = 1;
}

// If the current page is less than or equal to the first page, the calculation is based on the first page. If the current page is greater than or equal to the total number of pages, the calculation is the last page.
If (showpage <= 1)
{
Showpage = 1;
}
Else if (showpage> = pagecount)
{
Showpage = pagecount;
}

// Cursor position (current page-1) * page size + 1
Int posion = (showpage-1) * pagesize + 1;
// Set the cursor position
Rs2.absolute (posion );
Int I = 0;
// The pagesize of the data in the cyclic display table (records displayed on each page)
// Rs2.isafterlast () indicates whether the cursor has not been recorded after the last row
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.exe cutequery ("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.exe cutequery ("select title from ads_project where id =" + ads_project_id );
String projectname = "";
If (rs3.next ()){
Projectname = rs3.getstring ("title ");
} // Project name
%>


<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 ('20140901 ');"
Href = "./advertiser/./advertiser/banner_list.jsp #"> View </a> </TD>
<TD> <
Href = "./advertiser/banner_edit.jsp? Banner_id = 973 "> modify </a> </TD>
<TD> <a onclick = "return quantity ('000000 ')"
Href = "./advertiser/./advertiser/banner_list.jsp #"> Add a ticket </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">
Total <font color = Red> <% = rowcount %> </font> items & nbsp;
<Font color = Red> <% = pagesize %> </font> entries/Page & nbsp;
Page <font color = Red> <% = showpage %> </font>/total <font color = Red> <% = pagecount %> </font> & nbsp;
<A href = "./advertiser/banner_list.jsp? Showpage = 1 "target =" _ Self "> [homepage] </a> & nbsp;
<%
// Determine whether the "Previous Page" link is to be displayed
If (showpage> 1)
{
%>
<A href = "./advertiser/banner_list.jsp? Showpage = showPage-1 %> "target =" _ Self "> [Previous Page] </a> & nbsp;
<%
}
Else
{
%>
[Previous Page] & nbsp;
<%
}
// Determine whether the "next page" link is to be displayed
If (showpage <pagecount)
{
%>
<A href = "./advertiser/banner_list.jsp? Showpage = <% = showpage + 1%> "target =" _ Self "> [Next Page] </a> & nbsp;
<%
}
Else
{
%>
[Next Page] & nbsp;
<%
}
%>
<A href = "./advertiser/banner_list.jsp? Showpage = <% = pagecount %> "target =" _ Self "> [last page] </a> & nbsp;
Go
<Select name = "showpage">
<%
For (INT x = 1; x <= pagecount; X ++)
{
%>
<Option value = "<% = x %>" <% IF (showpage = x) out. println ("selected"); % >><%= X %> </option>
<%
}
%>
</SELECT>
Page & nbsp;
<Input type = "Submit" name = "go" value = "Submit"/>
</Form> </TD>










</Tr>

</Tbody> </table> </fieldset>
</Body>
</Html>
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.