Loans - Loans - Payday Loan - Loans - Mobile Phone

PDA

View Full Version : records in table


trixxarn
Sep 6th 2005, 1:16 pm
Hi!

I have an Access db and I want to display the records in the database in a table. I want to display 5 records on each row, so first it loop through the database and pick the 5 first records and then it creates a new row and pick the next 5 records etc.. So when it have picked out, say 15 records I want it to create a new page and the show the rest of the records on the second page, a paging system.

I have tested differents methods but without any results.

I would be grateful if someone can help me with this.

// trixxarn :cool:

vectorgraphx
Sep 8th 2005, 9:54 am
you need to create an incremental loop that counts up as you step through your recordset - and use an if...then statement to draw your cell/row opening and closing tags every 5 records.

something like
<table>
<%
i = 0 'your incremental loop - define it outside your recordset loop
while not recordset.eof 'start your recordset loop
if i = 0 or i mod 5 = 0 then
'insert your html to open the row/first cell
else
'insert your html to open the 2nd, 3rd, 4th, or 5th cell
end if
'display your recordset content
i = i + 1 'step up your incremental loop by 1.
if i = 0 or i mod 5 = 0 then
'insert your html to close the row/last cell
else
'insert your html to close the 1st, 2nd, 3rd, or 4th cell
end if
recordset.movenext 'proceed to the next record in the recordset.
wend
%>
</table>

and then create a link to the next page that adds 15 to the query that was passed to the page, i.e. if you pass "15" to the first page, add 15 to that and insert it dynamically as a variable in the hyperlink to the next page, and query the database based on that. Similarly, set your "previous" hyperlink to subtract 15 from that total passed to the page and dynamically add it to that hyperlink as a variable.

hth

VG