# How to limite number of loops for listing content of database table in asp?

**URL:** <https://forum.kirupa.com/t/how-to-limite-number-of-loops-for-listing-content-of-database-table-in-asp/35176>\
**Category:** Uncategorized\
**Created:** [November 11, 2003, 9:28am UTC](https://forum.kirupa.com/t/how-to-limite-number-of-loops-for-listing-content-of-database-table-in-asp/35176 "2003-11-11T09:28:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SBUH](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@SBUH](https://forum.kirupa.com/u/SBUH)\
**Post date:** [November 11, 2003, 9:28am UTC](https://forum.kirupa.com/t/how-to-limite-number-of-loops-for-listing-content-of-database-table-in-asp/35176/1 "2003-11-11T09:28:12Z")

</div>

Hello, in my database table there are 6 records. But on my first page which retrieve the data from table need only 2 records. And on the second page, I need to show all the records from the table but in the form of 3 records in each line.

I have before  
set rs=Server.CreateObject(“ADODB.recordset”)  
sql=“select name from mytable”  
rs.Open sql, conn  
do until rs.EOF  
Response.Write(rs(“name”))  
rs.MoveNext  
loop

But this will give all the records at the same time, how should I code so that for the first page, it can only output first two records. And on the second page, it can output in a form of 3 records in each line, so that there are two lines and 6 records altogether.

Thanks a lot in advance!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 7:24pm UTC](https://forum.kirupa.com/t/how-to-limite-number-of-loops-for-listing-content-of-database-table-in-asp/35176/2 "2003-11-11T19:24:26Z")

</div>

I’d pass the page number with the url (GET) and do something like

min = PageNumber\*2  
"SELECT name FROM mytable WHERE id\<min LIMIT 2"

I don’t do any asp, but i think you get the idea 😛
