Forum Moderators: open

Message Too Old, No Replies

Problem with displaying tables in pages

2 problems....

         

vanjamier

2:46 am on Jan 19, 2005 (gmt 0)

10+ Year Member



Hi
I did a function to display the tables in pages.
However i got 2 problems....

Problem 1 : The next and previous "links" are directed to the same page. This same page displays the first 50 records. So yea..previous and next is the "SAME" page.... :confused:

Problem 2 : The "JUMP to page" + count doesnt work...
the counter doesnt appear... :confused:


<!-- #include file="include/connections/database.inc" -->
<html>
<head>
<title>Mobile User Details</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body><center><STRONG><FONT color=red>Infineon Mobile Users</FONT></STRONG> </center><BR>
<%
Sub BuildNav (intPrev,intNext,TotalPages)
Dim counter
Response.Write "<font face=verdana size=1><b>"

' If the previous page id is not 0, then let's add the 'prev' link.
If intPrev <> 0 then
With Response
.Write "<a href=admin_view.asp?PageIndex="
.Write intPrev & "><< previous</a>"
.Write NBSP(5)
End With
End If

'This section displays the list of page numbers as links, separated with the pipe ( ¦ )
counter = 1
Response.Write "Jump to Page: "
do while counter <= TotalPages
'If the current page is the same as the counter,
'then write the page number with no hyperlink

If cint(counter) = cint(PageIndex) then
Response.Write counter
Else
' Else, let's write the page number as a hyperlink to that page
Response.Write "<a href=admin_view.asp?PageIndex="
Response.Write counter & ">" & Counter & "</a>"
End if

' As long as we're not at the last page number in this loop, let's add a pipe to the string.
If cInt(counter) <> TotalPages then
Response.Write " ¦ "
End If
counter = counter + 1
Loop

If (rs.AbsolutePage <> -3) then
With Response
.Write NBSP(5)
.Write "<a href=admin_view.asp?PageIndex="
.Write intNext & ">next >></a>"
End With
End If
End Sub
%>

<%
function NBSP(count)
dim i
for i = 1 to count
NBSP = NBSP + "&nbsp;"
next
end function
%>

<%
on error goto 0

Dim IntPageSize, PageIndex, TotalPages, TotalRecords
Dim RecordCount, RecordNumber

IntPageSize = 50
PageIndex = Request("PageIndex")
'If pageIndex is empty, set it to one.
if PageIndex = "" then PageIndex = 1

'open the database from database.inc file
OpenDatabase()

'RecordSet Object
Set rs = CreateObject("ADODB.RecordSet")
strsql = "select * from sunder.mobile_users"
rs.Open strsql, conn

RecordCount = rs.RecordCount
RecordNumber = (PageIndex * IntPageSize) - (IntPageSize)

rs.PageSize = intPageSize ' Set the number of records per page
'rs.AbsolutePage = PageIndex 'Define what page number on which
'the current record resides

dim intPrev, intNext
intPrev = PageIndex - 1
intNext = PageIndex + 1 'same as rs.AbsolutePage

Dim Count

'Building table headers
Dim disname(14)
disname(0) = "Name" disname(1) = "Phone_No" disname(2) = "Department" disname(3) = "Cost_Centre" disname(4) = "Model"
disname(5) = "IMEI" disname(6) = "Date_Of_Purchase" disname(7) = "Warranty_Card" disname(8) = "Singtel_A/C"
disname(9) = "Singtel_Plan_Types(Volume Discount)" disname(10) = "Singtel_One_Yr" disname(11) = "Electriclink_Two_Yr"
disname(12) = "Singtel_Two_Yr" disname(13) = ""
%>
<!-- Display Table -->
<table border="" cellspacing="1" cellpadding="2" borderColor=cornflowerblue borderColorDark=darkorange bgColor=white id=TABLE1>
<tr>
<% for i = Lbound(disname) to UBound(disname) -1 %>
<%Response.Write "<th>" & disname(i) & "</th>"
next%>
</tr>
<%
'Insert Data into table
If Not rs.EOF Then
Do While Not rs.EOF And Count < IntPageSize
%>
<tr>
<td><%=rs("NAME")%></td> <td><%=rs("PHONE_NO")%></td> <td><%=rs("DEPT")%></td> <td><%=rs("COST_CENTRE")%</td>
<td><%=rs("MODEL")%></td> <td><%=rs("IMEI")%></td> <td><%=rs("DATE_OF_PURCHASE")%></td>
<td><%=rs("WARRANTY_CARD")%></td> <td><%=rs("SINGTEL_ACCOUNT_NO")%></td> <td><%=rs("PLAN_TYPE")%></td>
<td><%=rs("SINGTEL_ONE_YR")%></td> <td><%=rs("ELECTRICLINK_TWO_YR")%></td> <td><%=rs("SINGTEL_TWO_YR")%></td>
</tr>
<%
rs.MoveNext
Count = Count + 1
Loop
%>
<%End If%>
</table>
<br>
<center>
<%
call BuildNav (intPrev,intNext,TotalPages)
'Close connection
rs.Close
Set rs = Nothing
%>
</center>
</body>
</html>

I hope can get suggestion from you guys..

Thanks in advance ..

vanjamier

3:05 am on Jan 19, 2005 (gmt 0)

10+ Year Member



Hihi, i solved problem number 1.
It had to do with setting the rs conn
cuz im Using Microsoft Oracle OLE DB Provider

But Im still stuck with problem number 2... :(
Problem 2 : The "JUMP to page" + count doesnt work...
the counter doesnt appear...