Hi there,

Why not just do it on the client side?

i.e. put a <div id="tablename"> or layer around your table headers, and then
in your <sql:resultSet>
<%
++counter;
%>

And then below your table:

<%
out.println("var counter="+Integer.toString(counter));
%>

<script>
if(counter==0)
{
    document.all.tablename.style.visiblity='hidden';
}
</script>


Something like that.

I have used that method a lot in other web applications where the
application didn't have any clue as how many rows fetched.


¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
Bjørn Bouet Smith
BSW
Stationsvej 23
DK-3480 Fredensborg
Tel. +45 4846 1313
Mob. +45 2448 5099
http://www.bsw.dk

¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨

----- Original Message -----
From: "Carole E. Mah" <[EMAIL PROTECTED]>
To: "Tag Libraries Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, April 30, 2002 3:02 PM
Subject: dbtags: rowCount


>
> Here is what it says in the doc:
>
> "The "rowCount" tag prints out the number of rows retrieved from the
> database. It can be used inside a ResultSet tag to provide a running count
> of rows retreived, or after the ResultSet tag to display the total number.
> See the Tag Reference for examples. Using the tag before the ResultSet
> will produce an error."
>
> Is there any way to test rowCount before the ResultSet?
>
> That is, if I have "catTable":
>
> catName  color           furType
> ----------------------------------
> Jasmine  Tortoise Shell  long
> Honey    Orange Tabby    short
> Corinna  Calico          short
> Pearl    Silver Tabby    long
>
> And my SELECT statement is:
>
> SELECT * FROM catTable WHERE color="Black";
>
> Then, because there does not seem to be a way to test the sql query to see
> if it returns zero rows, the table headings will always be printed, even
> if no table rows print (assuming for this example that the user chose
> "Black" for catColor in the HTML form):
>
> <%
>      String myColor = request.getParameter("catColor");
> %>
>
>
> <sql:statement id="stmt1" conn="conn1">
>
>   <sql:query>
>     SELECT * FROM catTable WHERE color='<%= myColor %>'
>   </sql:query>
>
>   <!-- I want to have a conditional test here
>        so that is the query above returns zero rows,
>        the following HTML does not get printed.
>   -->
>
>   <table>
>   <tr>
>     <td>catName</td>
>     <td>color</td>
>     <td>furType</td>
>   </tr>
>
>   <!-- need to NOT print the above HTML if zero rows
>        in query! -->
>
>   <sql:execute ignoreErrors="true"/>
>
>   <sql:resultSet id="rset2">
>     <tr>
>       <td><sql:getColumn colName="catName"/></td>
>       <td><sql:getColumn colName="color"/></td>
>       <td><sql:getColumn colName="furType"/></td>
>     </tr>
>   </sql:resultSet>
>
>   <!-- same here, don't print if zero rows -->
>   </table>
>   <!-- how? -->
>
> </sql:statement>
>
> That is, because of the ignoreErrors-"true", if there are zero rows,
> nothing gets printed out inside the resultSet block.  However, the
> literal table header row always gets printed.
>
> Thanks for any advice.
>
> -Carole
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Carole E. Mah                     [EMAIL PROTECTED]
>            Senior Programmer/Analyst
>    Brown University Scholarly Technology Group
>                phn 401-863-2669
>                fax 401-863-9313
>             http://www.stg.brown.edu/
>   personal: http://www.stg.brown.edu/~carolem/
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to