Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 11th, 2002, 06:06 PM
getchoo getchoo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 20 getchoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old March 12th, 2002, 05:20 AM
afabsy afabsy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 36 afabsy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
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>

Reply With Quote
  #3  
Old March 13th, 2002, 09:30 PM
getchoo getchoo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 20 getchoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old March 14th, 2002, 05:27 AM
getchoo getchoo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 20 getchoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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()

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > creating a new page with a link to it

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap