table header row every 10 lines

I have a huge table and I need to add the header row every 10 lines so when the user scrolls down, they don't lose the header.  I have some code to scroll lock, but i need this quick fix first.  this table loops through data from a mssql database.  Many thanks in advance.
meldraperAsked:
Who is Participating?
 
Walter RitzelSenior Software EngineerCommented:
I think this should do the trick...
<%rs=objConn.execute("select * from mytable")%>
<table>
<tr><th>Heading 1</th><th>Heading 2</th><th>Heading 3</th></tr>
<% limit = 10
      cnt = 1
     if not rs.eof then
do while not rs.eof
    if cnt = 11 then
         response.write "<tr><th>Heading 1</th><th>Heading 2</th><th>Heading 3</th></tr>" 
         cnt = 1
  end if
 response.write "<tr><td>" & value 1 & "</td><td>" & value 2 & "</td><td>" & value 3 & "</td></tr>"
cnt = cnt + 1
rs.movenext
loop
end if
%></table>

Open in new window

0
 
Walter RitzelSenior Software EngineerCommented:
Can you share your current code?
0
 
meldraperAuthor Commented:
so about every 10th record I need to include the heading

<%rs=objConn.execute("select * from mytable")%>
<table>
<tr><th>Heading 1</th><th>Heading 2</th><th>Heading 3</th></tr>
<%if not rs.eof then
do while not rs.eof
response.write "<tr><td>" & value 1 & "</td><td>" & value 2 & "</td><td>" & value 3 & "</td></tr>"
rs.movenext
loop
end if
%></table>

Open in new window

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
you're better off going with a fixed header. if you have visitors to your site with different screen resolutions, what may look right for one visitor (putting the header row every 10th line) will look very off for another visitor. The time it takes you to implement this solution would be very nearly the same time it would take to put in a css based fixed header solution.

here's a pretty straightforward tutorial on how to add css to your table to make a fixed header:

http://anaturb.net/csstips/sheader.htm

if you use jquery at all, you may want to look into datatables if you want more feautures, such as sorting, searching, paging etc
0
 
meldraperAuthor Commented:
Perfect!  Many thanks!!
0
 
meldraperAuthor Commented:
Big Monty, you are correct and I do have some code, but I needed a quick fix.  My headers are very involved with a lot of if statements for the groups they target and this was the fix i needed to get me through a meeting this morning.  thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.