|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
creating a new page with a link to it
Hi
I'm a beginner. I'm trying to display a fix number of records per page say for example 10 records per page. If it exceeds 10 records it will place the rest of the records in a new page with a link to the new page while the new page contains the link to the previous page. This process will repeat until all the records are displayed on each page. Sort of like what u see on forums. Is there a way to create new page dynamically with a link to it. Am I using the correct approach? Simple script will be greatly appreciated. Thanx getchoo ![]() |
|
#2
|
|||
|
|||
|
Hi,
yes you're on the correct way. you need to use only "Start" paramater for your page. E.g. you're at the position starting with 20, so: for previous: <a href="page.jsp?start=10">previous</a> for next: <a href="page.jsp?start=30">next</a> |
|
#3
|
|||
|
|||
|
I'm still unclear how this works
Hi so this code allows me to create an unlimited unumber or pages to display all my records. Here is a portion of my code.
rs=statement.executeQuery("SELECT students.studentid, students.firstname, students.lastname, students.email," + "btechpre.cisy1212, btechpre.cisy2311, btechpre.cisy2313, btechpre.cisy2314, btechpre.cisy2315," + "credential.recdate, credential.qualified, credential.accepted, credential.applied FROM students, btechpre, credential " + "WHERE students.studentid=credential.studentid AND credential.studentid=btechpre.studentid AND credential.recdate BETWEEN '"+startTime+"' AND '"+endTime+"' "); //SELECT DATE_FORMAT(date,'%M %d, %Y') from data while(rs.next()) { String cisy1212=rs.getString("cisy1212"); String cisy2311=rs.getString("cisy2311"); String cisy2313=rs.getString("cisy2313"); String cisy2314=rs.getString("cisy2314"); String cisy2315=rs.getString("cisy2315"); %> <tr bgcolor="#9999cc"> <td width="8%" height="18"><%= rs.getString("recdate")%></td> <td width="10%" height="18"><%= rs.getString("studentid")%><input type="hidden" name="studentid" value="<%= rs.getString("studentid")%>"></td> <td width="11%" height="18"><%=rs.getString("firstname")%> <%=rs.getString("lastname")%></td> <td width="15%" height="18"><a href="mailto:<%=rs.getString("email")%>"><%=rs.getString("email")%></a></td> <td width="13%" height="18"> <% if((cisy1212!=null) || (cisy2311 !=null) ||(cisy2313!=null) ||(cisy2314!=null) ||(cisy2315!=null)) %> <%=cisy1212%>,<%=cisy2311%>,<%=cisy2313%>,<%=cisy2314%>,<%=cisy2315%></td> <td width="15%" height="18"><%=rs.getString("cisy1212")%>,<%=rs.getString("cisy2311")%>,<%=rs.getString("cisy2313")%>,<%=rs.getString("cisy2314")%>,<%=rs.getString("cisy2315")%></td> <td width="6%" height="18"><%=rs.getString("qualified")%></td> <td width="6%" height="18"><%=rs.getString("applied")%></td> <td width="6%" height="18"><%=rs.getString("accepted")%></td> <td width="6%" height="18"> <input style="BACKGROUND-IMAGE: url(file://C:\jakarta-tomcat-4\webapps\CISY2415\images\trash2.gif); WIDTH: 28px; HEIGHT: 36px; BACKGROUND-COLOR: #9999cc" type=submit name=delete size=14 onClick="document.btechreport.action='deletebtech.jsp'"> </td> </tr> <% } //end while() //clean up if(rs!=null) rs.close(); if(statement!=null) statement.close(); if(connection!=null) connection.close(); %> </table> </form> so how do I use these tags in this code to display 10 records per page, where total number of records are unknown? Thanx getchoo |
|
#4
|
|||
|
|||
|
heres revised code, but it still doesn't work.
What is wrong with the portion of the code that creates links to new page that contains the additional records "its commented on the bottom" and they mention an error with the Limit fcn in my mysql statement. Heres the code:
while(rs.next()) { String cisy1212=rs.getString("cisy1212"); String cisy2311=rs.getString("cisy2311"); String cisy2313=rs.getString("cisy2313"); String cisy2314=rs.getString("cisy2314"); String cisy2315=rs.getString("cisy2315"); %> <tr bgcolor="#9999cc"> <td width="8%" height="18"><%= rs.getString("recdate")%></td> <td width="10%" height="18"><%= rs.getString("studentid")%><input type="hidden" name="studentid" value="<%= rs.getString("studentid")%>"></td> <td width="11%" height="18"><%=rs.getString("firstname")%> <%=rs.getString("lastname")%></td> <td width="15%" height="18"><a href="mailto:<%=rs.getString("email")%>"><%=rs.getString("email")%></a></td> <td width="13%" height="18"> <% if((cisy1212!=null) || (cisy2311 !=null) ||(cisy2313!=null) ||(cisy2314!=null) ||(cisy2315!=null)) %> <%=cisy1212%>,<%=cisy2311%>,<%=cisy2313%>,<%=cisy2314%>,<%=cisy2315%></td> <td width="15%" height="18"><%=rs.getString("cisy1212")%>,<%=rs.getString("cisy2311")%>,<%=rs.getString("cisy2313")%>,<%=rs.getString("cisy2314")%>,<%=rs.getString("cisy2315")%></td> <td width="6%" height="18"><%=rs.getString("qualified")%></td> <td width="6%" height="18"><%=rs.getString("applied")%></td> <td width="6%" height="18"><%=rs.getString("accepted")%></td> <td width="6%" height="18"> <input style="BACKGROUND-IMAGE: url(file://C:\jakarta-tomcat-4\webapps\CISY2415\images\trash2.gif); WIDTH: 28px; HEIGHT: 36px; BACKGROUND-COLOR: #9999cc" type=submit name=delete size=14 onClick="document.btechreport.action='deletebtech.jsp'"> </td> </tr> ////////////////////////////////////////////////diplaying 10 records per page////////////////////////////// //set number of rows per page int maxrowPage = 10; //initialize pagenumber to one( int pageNum = 1; int min = maxrowPage*(pageNum-1); if(pageNum>1) system.out.println("<A href=JSP_SELF?pageNum="+(pageNum-1)+">"Previous Page"</a>"); if(numProd>maxrowPage*(pageNum) system.out.println("<A href=JSP_SELF?pageNum="+(pageNum+1)+">"Next Page"</a>"); ///////////////////////////////////////////////////////////////////////////////////////////////////////////// <% } //end while() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > creating a new page with a link to it |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|