<%@ page import="java.sql.*" %> <%@ page import="java.io.*" %> National association for mentally ill : India



                                   

<%! Connection con; PreparedStatement pstmt,pstmt1,pstmt2; ResultSet rs,rs1; String name,email,query,brief; int i,msgid,count,counti,countj,j,k; %> <% try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:nami","",""); count = Integer.parseInt(request.getParameter("count")); counti = count+9; countj = 0; //System.out.println("Count : "+count); %>
Msgid
<% pstmt = con.prepareStatement("select * from msgboard"); rs=pstmt.executeQuery(); i=0; j=0; while(rs.next()) { i++; if(i>=count&&i<=counti) { j++; msgid=rs.getInt(1); name=rs.getString(2); query=rs.getString(3); pstmt1 = con.prepareStatement("select * from msgboard1 where msgid=?"); pstmt1.setInt(1,msgid); rs1=pstmt1.executeQuery(); k=0; while(rs1.next()) { k++; } %> <% } } count = count+10; %>

  <%= i %>.

  <%= query %>  (<%= k %>)
   ID - <%= msgid %> By <%= name %>

<% if(count>=16) { %>
Previouspage
<% } %>
Total messages - <%= i %>
<% if(j==10) { %>
Nextpage
<% } %>


Msgid
<% } catch(Exception e) { //System.out.println("Error : "+e.getMessage()); } %>