Oracle & JSP Development of small information Management System (vii) Source code 5

Source: Internet
Author: User
Tags count integer query string variable
js|oracle| Information Management | source code
Index.jsp improved implementation of the default page for classification queries

<%@ page contenttype= "Text/html;charset=big5"%> <%@ include file= "articleconn1.jsp"%><%

String types=request.getparameter ("types"); if (types==null) types= "null";

String Query=null; String Sqlname=null; %>
<script>

function Openwin (ID) {window.open ("view.jsp?id=" +id, "", "height=450,width=550,resizable=yes,scrollbars=yes,status =no,toolbar=no,menubar=no,location=no ");}

</script><link rel= "stylesheet" href= "Css/style.css" >
<body bgcolor= "#FFFFFF" topmargin= "0" leftmargin= "0" marginwidth= "0" marginheight= "0" ><table width= "609" Border= "0" cellspacing= "0" cellpadding= "0" align= "center" > <tr> <td> <div align= "center" >&  Lt;img src=http://www.163design.net/j/e/"images/title.jpg" width= "587" height= "174" ></div> </td> </tr></table>

<center> Categories View information: <a href= "Index.jsp?types=mp3" >>>mp3</a> <a href= "index.jsp?types=" Notebook ">>>notebook</a> <a href=" index.jsp?types=pc ">>>computer</a> <a href=" Index.jsp?types=mobile Phone ">>>mobile phone</a> </center><div align=" center "></div ><table width= "607" cellpadding= "0" cellspacing= "0" align= "center" > <tr> <td colspan= "3" height= "11 7 "> <table border=" 1 "width=" 100% "bordercolorlight=" #000000 "bordercolordark=" #FFFFFF "cellpadding=" 0 "cellsp             acing= "0" align= "center" > <tr> <td height= "bgcolor=" "#B5D85E" width= "81%" > <div align= "center" >

<p><font color= "#000000" ><strong> Information list </strong></font> </p> </div> </td> </tr> <tr> <td width= "81%" align= "center" valign = "Top" height= "139" > <div align= "Center" >

              <div align= "center" >                  <div align= "center" > <br>                   <br>                   <div align= "center" >                      <p align= "left" >                       <%int Intpagesize;int introwcount;//Total int intpagecount;//page int intpage;//page reference string strpage;//the definition variable is used to transfer pageint i,j;intpagesize=5;// Define the 5 record Strpage=request.getparameter ("page");//Get the Strpage==null {////The initial homepage, if no record is displayed, place the first home intpage=1;} Else{intpage=inTeger.parseint (strpage);//convert Strpage to Integer if (intpage<1) intpage=1;}

if (Types.equals ("null")) {Sqlname= select count (article_id) from learning;} Else{sqlname= "SELECT count (article_id) from learning where types= '" +types+ "";}

Sqlname= "SELECT count (article_id) from learning where title is"% "+keyword+"% ' and types like '% ' "+typename+" by article_id Desc ";

PreparedStatement ps=conn.preparestatement (sqlname); ResultSet rs1=ps.executequery (); Rs1.next (); Introwcount=rs1.getint (1);//Get integer save and Introwcount variable intpagecount= ( INTROWCOUNT+INTPAGESIZE-1)/intpagesize;//calculates the total number (record number + per page of the record-1)/per page recording) if (Intpage>intpagecount) intpage= Intpagecount;

if (Types.equals ("null")) {query= "SELECT * from Learning Order by article_id";} else{query= "SELECT * from learning where types= ' +types+" ' ORDER by article_id ';}

Ps=conn.preparestatement (query);//string query= "SELECT * from Learning Order by article_id";

ResultSet rs=ps.executequery (query),//Execute SQL, sort by time before i= (intPage-1) *intpagesize;for (j=0;j<i;j++) rs.next (); ><%--Settings intpage parameters--%>   <form action=index.jsp method=post><p ' center ' valign= ' bottom ' >     <%=intPage%> page     Total <%=intPageCount%> pages          <%if (intpage>1) {%>    <a href= "index.jsp?page=<%=intpage-1%>&types=<%=types%>" > previous page </a>            <%}%>        <%if (intpage <intpagecount) {%>    <a href= "index.jsp?page=<%=intpage+1%>&types=<%= Types%> "> next page </a>       <%}%>     </ form>                                          </div>                   <div align= "center" >                      <center>                       <table border= "1" cellspacing= " 0 "width=" 90%     bgcolor= "#F0F8FF" bordercolorlight= "#000000" bordercolordark= "#FFFFFF" background= ".. /images/top-linebg.gif ">                         <tr>                             &LT;TD width= "15%" align= "center" height= "bgcolor=" "#B5D85E" ><font color= "#000000" >id                               </font></td>                           &LT;TD Width= "45%" align= "center" bgcolor= "#B5D85E" ><font color= "#000000" > Letter                               name </font></td>                           <td width= "26%" align= "center" bgcolor= "#B5D85E" ><font color= "#000000" >                               Download Time </font></td>                           <td width= "15%" align= "center" Bgcolor= "#B5D85E" ><font color= "#000000" > Dot                              Attack </ font></td>                         </tr>                           <%if ( introwcount==0) {%>   , there is no information!     <%}else{%>  <%--shows the data per page (5 on each page according to the value of i)Recording)--%> <%  i=0;  while (I<intpagesize && rs.next ()) { %>                          <tr>                            <td width= "15%" height= "23" Bgcolor= "#FFFFFF" >                              <p align= "center" ><%= Rs.getstring ("article_id")%>                            </td>                            &LT;TD width= "45%" bgcolor= "#FFFFFF" >                               <a href= " Javascript:openwin (<%=rs.getstring ("article_id")%>) "title=" <%=rs.getstring ("title")%> "><%=" Rs.getstring ("title")%></a>                                                                               </td>                           <td width= "26%" Bgcolor= "#FFFFFF" &GT                              <div align= "center" ><%=rs.getstring ("Date_and_ Time ")%></div>                           </td>                            <td width= "15%" bgcolor= "#FFFFFF" >                              <p align= "Center" ><%=rs.getstring ("hits")%>                            </td>                          </tr>          <%   i++;// Pages per page via I loop     } %>         <%}%>                        </table>                     </center>                   </div>                <form action=index.jsp method=post><p align= ' center ' valign= ' bottom ' >      <%=intPage%> pages     Total <%=intPageCount%> page          &Nbsp; <%if (intpage>1) {%>    <a href= "index.jsp?page=<%=intpage-1%> &types=<%=types%> "> Previous pages </a>            <%}%>        <%if (Intpage<intpagecount) {%>     <a href= "index.jsp?page=<%=intpage+1%>&types=<%=types%>" > next page </a>        <%}%>        <br> to <input Type= "text" name= "page" size= "5" value= "1"/> page         <input type= "Submit" Value= "Make sure" class= "ButtonFace" >     </form>          <%               String username= (String) Session.getattribute ("admin");         if (username==null) { Username= "";}         if (username.equals ("admin")) {                  %>             <a href= "manage.jsp" > System Management </a><%}          else{%>            <a href= "login.jsp" > Login System Management </a><%}%>                          </div>               </div>             </div>          </td>         </tr>      </table>    </td>   </tr></table><%rs.close ();

Conn.close (); %> <p align= "center" >copyright©moonsoft 2004</p></body>





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.