免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1510 | 回复: 1
打印 上一主题 下一主题

分页显示没法显示第一页之后的,不知道哪里错了? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-09-28 10:33 |只看该作者 |倒序浏览
<%@page contentType="text/html;charset=gb2312"%>;
<html>;
<head>;
<meta http-equiv="Content-Language" content="zh-cn">;
<meta http-equiv="Content-Type"content="text/html;charset=gb2312">;
<title>;留言版</title>;
</head>;
<body bgcolor="#FF66FF">;
<%@page import="java.sql.*"%>;
<%--连接数据库使用的语句--%>;
<%
String url=new String();
String login=new String();
String password=new String();
String sql=new String();
login="tt";
password="123456";
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyan";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver";
Connection conn=DriverManager.getConnection(url,login,password);
%>;
<%
int pageLine=6;
int totalRec=0;
int totalSub=0;
int intPage=1;
if(request.getParameter("page"!=null)
intPage=Integer.parseInt(request.getParameter("page");
Statement stat=conn.createStatement();
ResultSet countrs=null;
try{
  countrs=stat.executeQuery("select count(*)as cnt from liuyan";
  if(countrs.next())
          totalRec=countrs.getInt("cnt";
}catch(Exception e){
    e.printStackTrace();
}finally{
        //countrs.close();
        stat.close();
}//取得留言的总页数
int intPageCount=0;
intPageCount=(totalRec+pageLine-1)/pageLine;
%>;

<table border="1" cellspacing="0" width="560" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF"bordercolordark="#ECF5FF">;
<tr align="center" bgcolor="#0099FF">;
<td width="30">;表情</td>;
<td width="60">;留言人</td>;
<td width="60">;留言时间</td>;
<td width="410">;留言内容</td>;
</tr>;
<%
//从数据库中取得留言的内容
int i=0;
int serial;
String emote="";
String name=new String();
String gettime=new String();
String content=new String();
Statement stat1=conn.createStatement();
ResultSet contentrs=null;
try{
   contentrs=stat1.executeQuery("select * from liuyan order by serial_no DESC";//这句可能页要根据情况修改
   if(intPageCount>;0){
           for(i=1;i<=(intPage-1)*pageLine;i++)
                   countrs.next();
           for(i=1;i<=pageLine;i++){
           if(contentrs.next()){
            emote=contentrs.getString("emote";
                name=contentrs.getString("name";
                gettime=contentrs.getString("guest_time";
                content=contentrs.getString("content";
                %>;
                <tr>;
                <td width="30" align="center">;<img src="images\<%=emote%>;.gif">;</td>;
        <td width="60" align="center">;<%=name%>;</td>;
                <td width="60" align="center">;<%=gettime%>;</td>;
                <td width="410">;<%=content%>;</td>;
                </tr>;
                <%
      
           }
           }
          // contentrs.next();
   }
}catch(Exception e){
         e.printStackTrace();
}finally{
        // contentrs.close();
         stat1.close();
         conn.close();
}
%>;
<%
  out.print("<TR>;");
if(intPageCount*pageLine<totalRec)
         intPageCount++;
if(intPage>;intPageCount)
         intPage=intPageCount;
if(intPage<1)
         intPage=1;
out.println("<form method=\"post\" name=fPageNum action=\"index.jsp\">;");
out.println("<center>;分页&");
         if(intPage<2)
         out.println("<font color=\"white\">;首页 上一页 </font>;");
     else{
         out.println("<a href=\"bbs.jsp?page=1\">;首页</a>;&");
         out.println("<a href=\"bbs.jsp?page="+(intPage-1)+"\">;上一页</a>;&");
                 }
        if(intPage-intPageCount>;=0)
                out.println("<font color=\"white\">;下一页 尾页</font>;");
                else
                out.println("<a href=\"bbs.jsp?page="+(intPage+1)+"\">;下一页</a>;&<a href=\"bbs.jsp?page="+intPageCount+"\">;尾页</a>;");
                out.print("&页次:<strong>;<font color=\"white\">;"+intPage+"</font>;/"+intPageCount+"</strong>;页");
                out.print("&共<b>;"+totalRec+"</b>;条留言<b>;"+pageLine+"</b>;条/页");
                out.print("&&转到第<input type=\"text\" name=\"page\" size=\"2\" maxlength=\"10\" class=smallInput value=\""+intPage+"\">;");
                out.print("页<input class=buttonface type=\"submit\" value=\"GO\" name=\"cmdok\">;</span>;</p>;</form>;");//注意这个cndok是不是cmdok,可能错了(改过了)
                out.print("</td>;");
                out.print("</tr>;");
                %>;
                </table>;
                <p align="center">;
        <form action="search.jsp"method="OST" name="search" target="_blank">;
                <font color="blue">;[查询留言]</font>;
                <input type="text" name="keywords" size="10">;
                <input type="submit" name="submit" value="查询">;&&&
                <a href="write.jsp"onClick="return newwin(this.href);">;[留言]</a>;&&
                <a href="manage.jsp" onClick="return
                newwin(this.href);">;[留言管理]</a>;&&
  </form>;
</table>;
<p align="center">;
<a href="javascript:window.close();">;关闭</a>;
</p>;
</body>;
</html>;
[code][/code]

论坛徽章:
0
2 [报告]
发表于 2004-09-29 08:31 |只看该作者

分页显示没法显示第一页之后的,不知道哪里错了?

已经搞定了!多谢各位看官!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP