Hi!

I want to display the results of an SQL query in a simple table. Since there
are many rows in the result-set, it would be nice if I could use alternating
colors for the rows (e.g. even row-numbers yellow, odd ones green).

To do this, I have to retreive the current rowCount as an int-value:


<table border="1" width="90%">
<sql:statement id="stmt1" conn="conn1"> 
  <sql:query>
    select usr_name, usr_mail from usr
    order by 1
  </sql:query>

  <sql:resultSet id="rset2">
    <%
        int    currentRow = ????? current row number ?????;
        String color      = (currentRow % 2) == 0 ? "#55ffff" : "#5555ff";
    %>

    <tr bgcolor="<%=color%>">
      <td><sql:getColumn position="1"/></td>
      <td><sql:getColumn position="2"/>
          <sql:wasNull>[no description]</sql:wasNull>
      </td>
    </tr>
  </sql:resultSet>
</sql:statement>
</table>

The question is, how do I get <sql:rowCount/> into the int-variable?
Or is there a better way to get multicolored tables?

TIA

Thomas

Reply via email to