473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

paging through records

Hello how do i do that when the articles in my site reach 5th article
its will automaticaly open new page like this :

article 1

article 2

article 3

article 4

article 5

Page 1 from 1 2 3 4 5... [ Previous Page ] [ Next Page ]

this is the code :

<%
path = Server.mappath("samples.mdb")
set con=Server.createobject("ADODB.Connection")
con.open "driver={Microsoft Access Driver (*.mdb)}; DBQ=" &path
Response.Write "<font color=blue>" & id & "</font>"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT * FROM `KATAVA` ORDER BY the_date DESC", con
do until rs.EOF
Response.Write "<table width=570 align=center><tr><td background=frame2copy.gif><br>"
Response.Write "<center>"
Response.Write(rs.fields("subject").value & "<center></center>")
Response.Write(rs.fields("the_date").value & "<br /><br><br>")
Response.Write "</center>"
Response.Write "<font align=right dir=rtl>"
Response.Write(rs.fields("brief_text").value & "<br /><br><br><br><br>")
Response.Write "</font>"
Response.Write "צפיות : "
Response.Write(rs.fields("hits").value & " <br /> </td><td>asdasa</td><td>asdsadasdasdadasdsadsadasd</td></tr></table>")
Response.Write "<a href=http://www.hypersonic.somee.com/New%20Folder/magazine_details.asp?id="
Response.Write(rs.fields("id").value & "><font size=2 color=8e9fc2 face=Verdana>לכתבה המלאה</font></a>")
Response.Write "<br><br><br>"
rs.MoveNext
loop
rs.close
con.close


%>

what should i type instead the do until rs.EOF ?
oh and i want it Page 1 from 1 2 3 4 5... [ Previous Page ] [ Next Page ]
thanks for help :)
Dec 27 '07 #1
3 1329
could someone answer please?
Dec 27 '07 #2
jhardman
3,406 Expert 2GB
could someone answer please?
This is called "paging" and different coders have different methods for doing this. I have changed the thread title to reflect this, hopefully someone else will look at it. By the way, bumping your thread by replying yourself probably discouraged others from looking at it. A lot of experts look specifically for posts that have no replies, and would have ignored yours.

I have never tried this, but I would try it like this: Instead of just looping through the records, try looping through five
Expand|Select|Wrap|Line Numbers
  1. for x = 0 to 4
  2.    if objRS.eof <> true then
  3.       'display data
  4.       objRs.movenext
  5.    end if
  6. next
The tricky part would be bookmarking in the db where you left off, a lot of db connections don't allow this, so you might have to save the record number where you left off or calculate where each new page begins, then put this data in the links to each page:
Expand|Select|Wrap|Line Numbers
  1. <a href="thisPage.asp?firstRecord=11">Page 3</a>
then you will of course need to move to the appropriate starting place before you begin reading records.

Let me know if this gives you any trouble.

Jared
Dec 31 '07 #3
idsanjeev
241 100+
i wants to paging bsed on topic posted by employee in more then 10 then paging otion to view next page first page is work fine but the page number don't work so how can paging it with employee number
error in line first page is worked but paging option does't work
error is Operation is not allowed when the object is open.

<%@ Language=VBScript%>
<%Option Explicit%>
<%
dim conn,R,vempno,stropt1,name,page,rcount,rpage,i
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=Oracle; USER ID=starter;PASSWORD=starter;"
Set R = Server.CreateObject("ADODB.Recordset")
for each stropt1 in request.QueryString
vempno=request.QueryString(stropt1)
R.open "select top_sub,launch_dt,no_of_reply,launch_by,empno from topmaster where empno='"&vempno&"' ", conn, adOpenStatic, adLockOptimistic, adCmdText
R.PageSize=10 ' 10 records per page
Rcount=r.RecordCount
Rpage=R.PageCount
if request.querystring("page")="" then
page=1
else
page=cint((request.querystring("page")))
end if
%>
<html>
<head>
<title>Voice Of Baraunians</title>
</head>
<body >
<style type="text/css">
body
{
background-color:#FFF0F4;
}
.aqua
{
font-size:24px; color:#261DDC;
}
.purple
{
font-size:17px; color:#C46209; font-family:sans-serif ;
}
.font
{
font size:20px; face:Geneva; color:#A85B06;
}
</style>
<!--#include file="front1.inc"-->
<div style="position:absolute; top:110; left:270">
<p style="text-align:center "><font color="#E05127" face="Georgia, Times New Roman, Times, serif" size="+3">User Profile</font></p>

<table border="0" width="500" bgcolor="#D2FFD8">
<tr class="aqua"><td align="center">Employee Number</font></td>
<td align="left"><%=R("empno")%></tr>
<tr class="aqua"><td align="center">User Name</font></td>
<td align="left"><%=R("launch_by")%></tr>
</table>
<table width="500" bgcolor="#FCDDD6" cellpadding="0" cellspacing="2" border="1">
<tr class="font"><td> Topic Subject</td>
<td>Reply</td>
<td>Launch Date</td></tr>
<%
' skip the dummy records
if not R.eof then
R.Move (page-1)*R.pagesize
end if
if not R.eof then
' Display the records
for i=1 to R.pagesize%>
<tr class="purple"><td><%=R("top_sub")%></td>
<td><%=R("no_of_reply")%></td>
<td><%=R("launch_dt")%></td></tr>
<%R.movenext
' Exit the loop when reaching the end of the recordset
If R.EOF Then Exit For end if
next
end if%>
</table>
<%next%>
<table width="500" border="0" cellspacing="1" cellpadding="3" >
<tr align="right" bgcolor="#FFFFFF">
<td> <%If page>1 Then %> <a href="userprofile1.asp?opt=<%=R("empno") %>&page=<%=page-1%>">Previous</a>
<%end if %>
<% If page < Rpage Then %> <a href="userprofile1.asp?opt=<%=R("empno")%>&page=<% =page+1 %>">Next</a>
<% end if %>
<%if Rpage>2 then
for i=1 to Rpage
%><a href="userprofile1.asp?opt=<%=R("empno")%>&page=<% =i%>">"&i&"</a>
<%
next
end if
%> </td>

</tr>
</table>
</div>
<table width="800">
<tr align="center"><td align="center"><input type="button" value="Home" onClick="brvoice()">
<input type="button" value="Exit" onClick="window.close()"></td></tr>
</table>
</div>
<script language="javascript">
function brvoice()
{
window.location = "brvoice.asp"
}
</script>
<% r.close%>
</body>
</html>

[/code]
Jan 1 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Navin | last post by:
HI, Guys There has been a lot of Ways to use paging in asp 1>Recordset approach -where whole records are pulled at client side... and then only the records which are needed are filtered.. and...
4
by: david | last post by:
Hi I have written code in ASP for paging records from the database (SQL Server 2000). The real problem I have around 10,000 records and it tries to fetch all the records everytime (I'm saying...
6
by: Shawn | last post by:
Hi. I already have a datagrid where I'm using paging. I have a stored procedure that fills a temp table with 200-500 rows and then sends back 10 records at the time. When I go to page 2 the SP...
2
by: asad | last post by:
Hello friends, i am designing a ASP.NET page where i want to use custom paging bcoz data is too heavy so pls tell me how can i use custom paging in ASP.NET Thanks
3
by: nyhetsgrupper | last post by:
Hi everyone, In a datagrid the entire data is read but only the page you want is displayed to the user when you enable paging. Does the Gridview control works in the same way? So if you have...
1
by: rbg | last post by:
I am using derived tables to Page data on the SQL Server side. I used this link as my mentor for doing paging on the SQL Serverhttp://msdn2.microsoft.com/en-us/library/ms979197.aspx I wanted to...
8
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be great. In my SQL query that selects data from table,...
2
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
3
by: Ronald S. Cook | last post by:
I was told that if calling lots of records from the database (let's say 100,000), that the GridView's paging feature would automatically "handle" everything. But the 100,000 records are still...
8
by: Donald Adams | last post by:
I heard in an online video by Scott Gu, that there is an option to have the asp.net datagrid in .net 2.0 do the paging in SQL Server 2005 rather than pull all the data from the database and do it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.