Skip to main content
Participant
October 31, 2009
Question

Rownumbers in dynamic table

Has anybody any idea how to show/insert rownumbers in a dynamic table, supplied by SQL Server? Everything is working fine, but the finishing touch would be the row-numbers. This issue comes in handy when reading a large table.

Thanks in advance.

Robert alias slot20

This topic is closed to new replies. Start a new post to keep the conversation going.

6 replies

David_Powers
Inspiring
October 31, 2009

slot20 wrote:

Has anybody any idea how to show/insert rownumbers in a dynamic table, supplied by SQL Server?

If you're using SQL Server, you're probably using ASP. I don't know the ASP syntax, but the basic principle is to use a variable as a counter, increment it with each iteration of the loop that displays the table, and display it.

In PHP, you would initialize the counter outside the table like this:

  $i = 1;

And inside the table:

  echo $i++;

Translate
slot20Author
Participant
November 1, 2009

David,

I think that your technic is the right one. Y're also right: I use Classic ASP, but I am no expert on that matter. So I cannot translate your suggestion in ASP, f.e. "echo" does not give any results. To give you any idea of the code in question see below:

<table border="1" cellpadding="0" cellspacing="1" class="tabel46">
  <tr bgcolor="#FFCC00" class="tabel46">
    <th>Coureur</th>
    <th>Aantal Finishes</th>
    </tr>
  <% While ((Repeat1__numRows <> 0) AND (NOT rsAantalFinishes.EOF)) %>
    <tr>
      <td nowrap="nowrap"><%=(rsAantalFinishes.Fields.Item("Coureur").Value)%></td>
      <td><div align="center"><%=(rsAantalFinishes.Fields.Item("Aantal Finishes").Value)%></div></td>
      </tr>
    <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsAantalFinishes.MoveNext()
Wend
%>
</table>


I have to add a new field in combination with (perhaps) the index? Is there another forum (on ASP f.i.) where I could put this question?

I hope to hear from you once more.

Thanks,

Robert

Translate
Participating Frequently
November 2, 2009

Robert, your script already has a counter built in - Repeat1__index

Just use that in the first table cell:

<td><% = (Repeat1__index) %> </td>

At this point, I would strongly urge you to take a break from coding your website and spend a week learning the basics of ASP/VBScript. We all have to start somewhere, but learn-as-you-code will be extemeley frustrating and result in poor quality code. There a plenty of great classic asp sites with tutorials, but you may want to get one of the SAM's books on the subject. Good luck.

Translate
RJweb
Inspiring
October 31, 2009

don't know the answer, but it might be better to ask at

sorry forgot where I was, duh

Translate