表格 链接

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="qrnu.db.ConMysql" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<%     ResultSet rs=new ConMysql().syQuery();
	   int pagesize=10;
	   rs.first();
	   rs.last();
	   int RecordCount=rs.getRow();
	   rs.first();
	   int maxPage=0;
	   maxPage=(RecordCount%pagesize==0)?(RecordCount/pagesize):((RecordCount/pagesize)+1);
%>
<SCRIPT language=javascript>
	function openwin(id) { 
		window.open('stop.jsp?record='+id,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=0,resizable=no,width=620,height=480,left=120,top=80'); 
		}
</SCRIPT>


<style type="text/css">
<!--
#Layer1 {
	position:absolute;
	width:279px;
	height:24px;
	z-index:1;
}
-->
</style>
</head>

<body>
<%
  String str=(String)request.getParameter("Page");
	   if(str==null){
	   		str="0";
			}
		  int Page=Integer.parseInt(str);
	   if(Page<1){
	   		Page=1;
			}else{
			if(Page>maxPage){
				Page=maxPage;
			}
		}
		rs.absolute((Page-1)*pagesize+1);
		
  %>
<table width="286" border="1">
  <tr>
    <td width="86">city_id</td>
    <td width="184">province</td>
  </tr>
  
  <% for(int i=1;i<pagesize&&rs.next();i++){  %>
  
  
  
			<tr  onClick="openwin('<%=i+(Page-1)*pagesize+1%>')" onMouseOver="this.className='a'" onMouseOut="this.className='b'" 
				
			
			
			
			
			
			>
			
			
			
			
			
			
			<td><% String s=rs.getString(1);out.print(s);%></td>
			<td><% String s2=rs.getString(2);out.print(s2);%></td>
		
		</tr>
		<% }%>
</table>
<table width="287" border="1">
  <tr>
    <td width="67">
	<%if(Page>1){%><a href="pagedisplay.jsp?Page=1">第一页</a>
	<%}%></td>
    <td width="27">
	<%if(Page<maxPage){%><a href="pagedisplay.jsp?Page=<%=maxPage%>">末页</a>
	<%}%></td>
    <td width="49">
	<%if(Page>1){%>
	<a href="pagedisplay.jsp?Page=<%=Page-1%>">前一页</a>
	<%}%></td>
    <td width="62">
	<%if(Page<maxPage){%><a href="pagedisplay.jsp?Page=<%=Page+1%>">下一页</a>
	<%}%></td>
    <td width="48">第
      <form id="form1" name="form1" method="post" action="pagedisplay.jsp">
        <input type="text" name="Page" />
            </form>
    页</td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
 
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="qrnu.db.ConMysql" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<%	int b;
	String a=request.getParameter("record");
	if(a==null){
		b=1;
		}else{
		b=Integer.parseInt(a);
		}
	ResultSet rs=new ConMysql().transform(b);
	 
%>
<table width="486" border="1">
  <tr>
    <td width="102">city_id</td>
    <td width="95">province</td>
    <td width="139">city</td>
    <td width="122">ses</td>
  </tr>
  <tr>
    <td><%=rs.getString(1)%></td>
    <td><%=rs.getString(2)%></td>
    <td><%=rs.getString(3)%></td>
    <td><%=rs.getString(4)%></td>
  </tr>
</table>
</body>
// Java Document
package qrnu.db;
import java.sql.*;
public class ConMysql{
	public ResultSet syQuery(){
		 Statement stmt = null;
		 ResultSet rs = null;
		try {
	//out.write("cheng");
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	//out.write("cheng\r\n");
    Connection conn =DriverManager.getConnection("jdbc:mysql://219.218.24.206/sanyun?" + 
                                   "user=teacher&password=123");
    
	stmt = conn.createStatement();
    rs = stmt.executeQuery("SELECT * FROM city_info");
	}catch (Exception ex) {
   
    }
return rs;
}	public ResultSet syQuery1(String id){
		 Statement stmt = null;
		 ResultSet rs = null;
		try {
	//out.write("cheng");
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	//out.write("cheng\r\n");
    Connection conn =DriverManager.getConnection("jdbc:mysql://219.218.24.206/sanyun?" + 
                                   "user=teacher&password=123");
    
	stmt = conn.createStatement();
    rs = stmt.executeQuery("SELECT * FROM city_info where city_id="+
				id);
	}catch (Exception ex) {
   
    }
return rs;
}	
public ResultSet transform(int n){
		 ResultSet rs=new ConMysql().syQuery();
		try{ rs.absolute(n);}
		catch(Exception e1){
		}
		return rs;
}

} </html>
 

你可能感兴趣的:(sql,mysql,jsp,jdbc,XHTML)